This is the first time that I'm trying to use flutter_math_fork 0.7.2 package to display Tex equations but it does not even compile due to the following error ("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.
My code:
import 'package:flutter_math_fork/flutter_math.dart';
...
child: choicesContainsTexEquation ? Text(text) : Math.tex(text),
The variable text
above is read from a JSON file. With both texts (decoded as Strings) below, the same error occurs (whether trying to run on Android emulator or Chrome):
"text":"test"
and "text": "e^{i\\pi}+1=0"
On pubspec.yaml
:
dependencies:
flutter:
sdk: flutter
flutter_math_fork: ^0.7.2
What could be the issue?
I've tried changing both the text (using a Tex equation or "plain" text) and the platform (Android emulator and Chrome), and the same error occurs.
The issue here is in package itself. I guess this package is poorly maintained lately, so things like this may happen.
I think the only thing you can do, if you really depend on this package, is to use a fork where this particular problem fixed. Or maybe create your own fork with fixes.
I searched GitHub a little and found fork where your problem is fixed, here: https://github.com/Telosnex/flutter_math_fork_fork.git Particularly, here is commit with fix.
You can try to use it in your project, just modify tour podspec.yaml
like this:
flutter_math_fork:
git: https://github.com/Telosnex/flutter_math_fork_fork.git
But, more creating your own fork with fixes is more robust way, in my opinion.