In this post, we are going to show you how to solve "packages have newer versions incompatible with dependency constraints" error in Flutter. This error occurs when you have outdated packages added on pubspec.yaml file. See the solution below to solve this issue:
Changed 25 dependencies! 14 packages have newer versions incompatible with dependency constraints. Try `flutter pub outdated` for more information.
To solve this error, you need to update the version of each package and plugin to the latest version at pubspec.yaml file. Or you can solve it from the command terminal with the commands below:
flutter pub outdated
This command will give you the list of packages that are outdated and needs to increase the version to the latest version.
Showing outdated packages. [*] indicates versions that are not the latest available. Package Name Current Upgradable Resolvable Latest direct dependencies: dio *3.0.10 *3.0.10 4.0.6 4.0.6 font_awesome_flutter *9.2.0 *9.2.0 10.1.0 10.1.0 image_picker *0.6.5+3 *0.6.5+3 0.8.5+3 0.8.5+3 path *1.8.1 *1.8.1 *1.8.1 1.8.2 dev_dependencies: flutter_lints *1.0.4 *1.0.4 2.0.1 2.0.1 transitive dependencies: async *2.8.2 *2.8.2 *2.8.2 2.9.0 string_scanner *1.1.0 *1.1.0 *1.1.0 1.1.1 transitive dev_dependencies: lints *1.0.1 *1.0.1 2.0.0 2.0.0 7 dependencies are constrained to versions that are older than a resolvable version. To update these dependencies, edit pubspec.yaml, or run `flutter pub upgrade --major-versions`.
These are the list of packages and dependencies which needs to update their versions. You can increase the version by editing the version code at pubspec.yaml file manually or hit the command below:
flutter pub upgrade --major-versions
Now, hit the commands below:
flutter pub get
Now run your app, and the error may be got solved.
In this way, you can solve the "packages have newer versions incompatible with dependency constraints" error in Flutter.