Flutter Error: The method ‘toInt‘ isn‘t defined for the class ‘Decimal‘

1. Run the project and report an error:

insert image description here

2. Analysis of the cause of the error:

It can be seen from the error log that the decimal-2.0.0 dependency library in the common_utils plugin reported an error.
It is guessed that the upgraded version of decimal may cause incompatibility.
Open https://pub.flutter-io.cn/, search for decimal, and check the changelog and versions:
insert image description here

insert image description here

It was found that the library api was upgraded. However, our project did not actively integrate this library. Through the flutter pub deps command to check the dependencies of the third-party plug-ins used by the current project, we know that this
decimal library is a dependency of the common_utils 2.0.2 reference in flustars 2.0.1. . . . Nested to the third layer of dependencies. . . However, the latest version 2.0.1 of flustarts still has not been adapted.

3. Solution:

Return the decimal plugin to the version before the upgrade, which is version 1.5.0.
Downgrade the version number of the decimal plugin from 2.0.0 to 1.5.0 in pubspec.lock:
insert image description here

Then click the pubspec.yaml file, click pub get in the upper right corner (do not enter the command flutter pub get in the Terminal command line, this will re-pull the latest version 2.0.0 of the decima plugin and cause conflicts) and then you can run the project and package
normally up.

Guess you like

Origin blog.csdn.net/Jackson_Wen/article/details/121629112