Issue
Updated vector_math dependency to latest (2.1.0) in a flutter project and project now fails to build with error:
The argument type 'Vector2 (where Vector2 is defined in /mnt/data/work/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/src/vector_math_64/vector2.dart)' can't be assigned to the parameter type 'Vector2 (where Vector2 is defined in /mnt/data/work/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/src/vector_math/vector2.dart)'. (Documentation)
Vector2 is defined in /mnt/data/work/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/src/vector_math_64/vector2.dart (vector2.dart:10).
Vector2 is defined in /mnt/data/work/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/src/vector_math/vector2.dart (vector2.dart:10).
How does one resolve this? Is this a flutter issue or is issue in vector_math package?
Solution
Check the packages that were imported, the error is due to the the types being imported from different libraries.
vector_math
and vector_math_64
should be for 32bit
and 64bit
variants, they are implemented as two different libraries in the package. So you'd need to maintain consistency in how you the libraries are used.
A possible solution to not face this issue in the future is to export the types from a base package and import that types as needed from the base_package, this will protect users of the base_package from needing to know the what types are required or having this issue again.
For example: lib/base_package.dart
export 'package:vector_math/vector_math_64.dart'
or
export 'package:vector_math/vector_math.dart'
Answered By - Rohan Thacker
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.