I’m working on a Flutter app and I want to install the wakelock_plus
plugin: https://pub.dev/packages/wakelock_plus
Here’s the output when I run flutter pub add wakelock_plus
:
The current Dart SDK version is 2.19.4.
Because flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 depends on flutter_svg >=0.22.0 <1.0.0 which depends on xml ^5.0.0, flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 requires xml ^5.0.0.
And because dbus >=0.7.4 depends on xml ^6.1.0, flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 is incompatible with dbus >=0.7.4.
And because wakelock_plus <1.2.0 depends on dbus ^0.7.8 and wakelock_plus >=1.2.0 requires SDK version >=3.3.0 <4.0.0, flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 is incompatible with wakelock_plus.
So, because APP_NAME depends on both flutter_html ^2.2.1 and wakelock_plus any, version solving failed.
pub finished with exit code 65
I’ve been trying to decipher this for a few hours and I can’t figure out if there’s a way around the dependency conflict.
Anyone have a suggestion?
2
Answers
FOUND A SOLUTION
I determined that the issue was caused by the underlying
flutter_svg
package required byflutter_html
.Adding the following to my
pubspec.yaml
eliminated the dependecy.Found the solution here: https://github.com/Sub6Resources/flutter_html/issues/978
Run
flutter pub deps
on the console to get all your dependencies version recursively printed as a treeify map:Then search the name of conflict package one by one on the website https://pub.dev to confirm that if there is a newer/older version than yours. So you can try to upgrade/downgrade the version gradually on pubspec.yaml and rerun
flutter pub get
to check if your execution is successful (error message shows less than before).The worst situation is you even have to upgrade the dart version to solve the problem.
Repeat above operations again and again until there is no error message shows (aiming to make sure that all the version condition satisfies all the conflict packages’ version requirement). The key is to keep the same package in your project and also the dependencies in use, they all must share the same version meanwhile.
The most useful way to use a specific package version forcedly to against using the highest one by Dart is as follows (for example):