Flutter Math(用于在 Flutter 中显示方程:flutter_math_fork 0.7.2)甚至由于“hashCode”方法未定义或未找到而无法编译

问题描述 投票:0回答:1

希望你一切都好!

这是我第一次尝试使用 flutter_math_fork 0.7.2 包来显示 Tex 方程,但由于以下错误,它甚至无法编译(

"hashValues" is not found or defined
):

flutter run
Launching lib/main.dart on sdk gphone x86 in debug mode...
../../.pub-cache/hosted/pub.dev/flutter_math_fork-0.7.2/lib/src/widgets/selectable.dart:603:23: Error: The method 'hashValues' isn't defined for the class 'SelectionStyle'.
 - 'SelectionStyle' is from 'package:flutter_math_fork/src/widgets/selectable.dart' ('../../.pub-cache/hosted/pub.dev/flutter_math_fork-0.7.2/lib/src/widgets/selectable.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashValues'.
  int get hashCode => hashValues(
                      ^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/flutter_math_fork-0.7.2/lib/src/ast/options.dart:400:7: Error: The method 'hashValues' isn't defined for the class 'FontOptions'.
 - 'FontOptions' is from 'package:flutter_math_fork/src/ast/options.dart' ('../../.pub-cache/hosted/pub.dev/flutter_math_fork-0.7.2/lib/src/ast/options.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashValues'.
      hashValues(fontFamily.hashCode, fontWeight.hashCode, fontShape.hashCode);
      ^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/flutter_math_fork-0.7.2/lib/src/ast/options.dart:434:7: Error: The method 'hashValues' isn't defined for the class 'PartialFontOptions'.
 - 'PartialFontOptions' is from 'package:flutter_math_fork/src/ast/options.dart' ('../../.pub-cache/hosted/pub.dev/flutter_math_fork-0.7.2/lib/src/ast/options.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashValues'.
      hashValues(fontFamily.hashCode, fontWeight.hashCode, fontShape.hashCode);
      ^^^^^^^^^^
Target kernel_snapshot_program failed: Exception


FAILURE: Build failed with an exception.

我的代码:

import 'package:flutter_math_fork/flutter_math.dart';
...
child: choicesContainsTexEquation ? Text(text) : Math.tex(text),

上面的变量

text
是从json文件中读取的。对于下面的两个文本(解码为字符串),会发生上面相同的错误(都尝试在 android 模拟器或 chrome 上运行):

"text":"test"
"text": "e^{i\\pi}+1=0"

pubspec.yaml

dependencies:
  flutter:
    sdk: flutter

  flutter_math_fork: ^0.7.2

可能是什么问题?

非常感谢!

我尝试更改文本(使用 Tex 方程或“纯”文本)和平台(android 模拟器和 chrome),但出现了相同的错误。

flutter equation
1个回答
0
投票

这里的问题在于包本身。我猜这个包最近维护得不好,所以可能会发生这样的事情。

我认为,如果你真的依赖这个包,你唯一能做的就是使用一个叉子来解决这个特定的问题。或者也许可以通过修复创建您自己的分叉。

我在 GitHub 上搜索了一下,发现 fork 解决了你的问题,在这里:https://github.com/Telosnex/flutter_math_fork_fork.git 特别是,这里是带有修复的commit

你可以尝试在你的项目中使用它,只需修改tour

podspec.yaml
,如下所示:

  flutter_math_fork:
    git: https://github.com/Telosnex/flutter_math_fork_fork.git

但是,在我看来,更多地创建自己的分支并进行修复是更稳健的方式。

© www.soinside.com 2019 - 2024. All rights reserved.