error in using latest 1.1.0: vector_math error
Describe the bug Bumped to v1.1.0 recently, got the following error when trying to run the project
- 'Matrix4' is from 'package:vector_math/vector_math_64.dart' ('../../../../../../.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/vector_math_64.dart').
Try correcting the name to the name of an existing method, or defining a method named 'translateByDouble'.
..translateByDouble(
^^^^^^^^^^^^^^^^^
../../../../../../.pub-cache/hosted/pub.dev/fl_chart-1.1.0/lib/src/chart/base/custom_interactive_viewer.dart:534:9: Error: The method 'scaleByDouble' isn't defined for the class 'Matrix4'.
custom_interactive_viewer.dart:534
- 'Matrix4' is from 'package:vector_math/vector_math_64.dart' ('../../../../../../.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/vector_math_64.dart').
Try correcting the name to the name of an existing method, or defining a method named 'scaleByDouble'.
..scaleByDouble(clampedScale, clampedScale, clampedScale, 1);
^^^^^^^^^^^^^
../../../../../../.pub-cache/hosted/pub.dev/fl_chart-1.1.0/lib/src/chart/base/custom_interactive_viewer.dart:1114:7: Error: The method 'translateByDouble' isn't defined for the class 'Matrix4'.
custom_interactive_viewer.dart:1114
- 'Matrix4' is from 'package:vector_math/vector_math_64.dart' ('../../../../../../.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/vector_math_64.dart').
Try correcting the name to the name of an existing method, or defining a method named 'translateByDouble'.
..translateByDouble(rect.size.width / 2, rect.size.height / 2, 0, 1)
^^^^^^^^^^^^^^^^^
../../../../../../.pub-cache/hosted/pub.dev/fl_chart-1.1.0/lib/src/chart/base/custom_interactive_viewer.dart:1116:7: Error: The method 'translateByDouble' isn't defined for the class 'Matrix4'.
custom_interactive_viewer.dart:1116
- 'Matrix4' is from 'package:vector_math/vector_math_64.dart' ('../../../../../../.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/vector_math_64.dart').
Try correcting the name to the name of an existing method, or defining a method named 'translateByDouble'.
..translateByDouble(-rect.size.width / 2, -rect.size.height / 2, 0, 1);
^^^^^^^^^^^^^^^^^
To Reproduce Just bump the fl_chart to 1.1.0
Screenshots If applicable, add screenshots, or videoshots to help explain your problem.
Versions
- which version of the Flutter are you using?
- flutter: 3.32.6
- dart: 3.8.1
- which version of the FlChart are you using?
- 1.1.0
The same:(
same
same, looks like vector_math 2.2.0 is needed, but mine is pinned at a lower version by flutter test.. maybe updating flutter/dart will help, trying this now
yep ok, this worked 👍 so I had a dependency on vector_math ^2.1.4 which was imposed by flutter_test. running flutter upgrade updated flutter_test, allowing me to remove the pinned dependency on vector math. This now uses the version bundled with flutter and works 🙌
But i have latest version of the flutter which is 3.32.8. still get this issue @HLDavidE
But i have latest version of the flutter which is 3.32.8. still get this issue @HLDavidE
latest as of now is 3.35.2, but I recommend to use 3.35.1 as latest has an issue in console outputs
solved for me by removing "^": fl_chart: ^1.0.0 > fl_chart: 1.0.0
Hi @imaNNeo Could you take a look
Hi, sorry for my late reply. I was busy.
Our vector_math dependency was outdated.
So I just upgraded the version. I think that solves the problem.
Please try fl_chart 1.1.1 and let me know if the issue is gone.
Updating packages with flutter 3.32 (which I'm still stuck with unfortunately...) still gives me version 1.1.0 of fl_chart because vector_math is pinned to the earlier version there. Explicitly setting 1.1.1 gives the following error, that explains the real problem that we have here:
Because every version of integration_test from sdk depends on vector_math 2.1.4 and fl_chart >=1.1.1 depends on vector_math ^2.2.0, integration_test from sdk is incompatible with fl_chart >=1.1.1. So, because your_app depends on both fl_chart ^1.1.1 and integration_test from sdk, version solving failed.
Basically the solution here would be to retract 1.1.0 (not possible anymore because the 7 day period for that has already passed) which has the incorrect vector_math dependency. Not sure if there'S a possibility to still do that.
I believe that another solution would be to re-release the outdated 1.0.0 with a new (newest) version number, followed by re-releasing the working 1.1.1 version as a newer version again.
Please read this thread: https://github.com/Esri/arcgis-maps-sdk-flutter-toolkit/pull/77
This is the simplified detail of the issue:
Flutter 3.32 pins vector_math to exactly 2.1.4. Flutter 3.35 pins vector_math to exactly 2.2.0.
fl_chart 1.1.0 (and earlier) use "vector_math: ^2.1.4", which is compatible with Flutter 3.32 (and earlier).
fl_chart 1.1.1 (and later) use "vector_math: ^2.2.0", which is compatible with Flutter 3.35 (and later).
So if you're using Flutter 3.32 (and earlier), you should use fl_chart 1.1.0 If you're using Flutter 3.35 (and later), you should use fl_chart 1.1.1
Or you can use any version, but use dependency overrides to override the vector_math version that matches your Flutter version
Please read this thread: Esri/arcgis-maps-sdk-flutter-toolkit#77 So if you're using Flutter 3.32 (and earlier), you should use fl_chart 1.1.0 If you're using Flutter 3.35 (and later), you should use fl_chart 1.1.1
Sorry but this conclusion is wrong IMHO. fl_chart 1.1.0 depends on functions in vector_math that are only available in 2.2.0 of vector_math but not in 2.1.4: fl_chart 1.1.0 didn't increase the required vector_math version in its pubspec, this was only done in 1.1.1 . That's why dependency resolution when updating packages on old flutter versions picks up fl_chart 1.1.0 when it should only pick up 1.0.0. The result is the runtime (not compile-time!) error in the description of this issue. So my suggestion from above still stands ;-)
i have faced with this problem and using flutter 3.29.3 i removed ^ in pubspec and solved problem
fl_chart: ^1.0.0 => fl_chart: 1.0.0
I think we can resolve this issue as it is not fl_chart's issue and there are already workarounds. What do you guys think?