Flutter version solving failed error -[after Flutter 2 upgrade]

I know Stack Overflow and GitHub are full of the question for flutter 2 that is version solving failed, a dependency depends on another dependency… Here I am going to give you two solutions to this problem.

Pratik Butani
3 min readMar 6, 2021

I am so happy after the announcement of Flutter 2. Hopefully, you too. This is my first article on Flutter and it will help many developers for sure.

Flutter 2 —Google Developers Blogs

I have just started working on Flutter before few months only. I am super excited to go with Flutter now.

I developed one application 6 months back in Android that I am converting to Flutter and it's almost ready!

I know all the developers facing dependency issues in Flutter after upgrading Version 2.

Here are some examples of errors that may you got in the past or you will get in the feature.

Example 1: Firebase Dependencies Error

Because firebase_remote_config 0.6.0 depends on firebase_core ^0.7.0 and no versions of firebase_remote_config match >0.6.0 <0.7.0, firebase_remote_config ^0.6.0 requires firebase_core ^0.7.0. So, because flutter_demo depends on both firebase_core ^1.0.0 and firebase_remote_config ^0.6.0, version solving failed. pub get failed (1; So, because flutter_demo depends on both firebase_core ^1.0.0 and firebase_remote_config ^0.6.0, version solving failed.)

Example 2: Flutter Location Notification Error

Because flutter_local_notifications_platform_interface 2.0.0+1 depends on plugin_platform_interface ^1.0.2 and no versions of flutter_local_notifications_platform_interface match >2.0.0+1 ❤.0.0, flutter_local_notifications_platform_interface ^2.0.0+1 requires plugin_platform_interface ^1.0.2. So, because flutter_demo depends on both flutter_local_notifications_platform_interface ^2.0.0+1 and plugin_platform_interface ^2.0.0, version solving failed. pub get failed (1; So, because flutter_demo depends on both flutter_local_notifications_platform_interface ^2.0.0+1 and plugin_platform_interface ^2.0.0, version solving failed.)

and many more errors posted on Stackoverflow and GitHub by many developers.

I know you are waiting for a solution, here it is:

Solution 1:

The simplest solution is if you are doing some important and deadline work and you don't want to take any risk, you can use an older version of Flutter only.

If you have already upgraded Flutter 2, You can downgrade the older version using flutter downgrade

Note: Must try everything on new or older Flutter after taking a backup of your project.

Solution 2:

If you are just learning and not doing any deadline work then you can try this option because it's all about trial-n-error.

Use a new section in pubspec.yaml named `dependency_overrides:` [Documentation]

You can use dependency_overrides it to temporarily override all references to a dependency.

Here is the older version of my pubspec.yaml which is working before upgrading to Flutter 2. I got the errors in as it is pubspec after upgrading Flutter 2. After trying for 2 days I got a solution using dependency_overrides.

And finally here is the new pubspec.yaml, In which you can check some dependency added to dependency_overrides.

How to do it:

You can check which dependency is dependent on another dependency. You can write that dependency in dependency_overrides:

dependency_overrides:
firebase_auth: “>=1.0.0”
firebase_core: “>=0.7.0”
firebase_messaging: “>=8.0.0-dev.14”
firebase_remote_config: “>=0.6.0”
firebase_auth_web: “>=0.2.0”
firebase: “>=7.0.0”
flutter_local_notifications: “>=4.0.0”

As of now, At the time of writing this blog, It is working for me, you can change version changes as per your needs.

Warning: Using a dependency override involves some risk. For example, using an override to specify a version outside the range that the package claims to support, or using an override to specify a local copy of a package that has unexpected behaviors, may break your application.

Hopefully, someone will get help or a clue from it.

If you have any questions, free feel to ping me any time.

Be Independent :P

Keep Clapping 👏 (You can clap up to +50)

Your love is everything to me. Keep Appreciating.

Thank you for reading. ❤ ❤ ❤

Let’s be friends: LinkedIn, Facebook, Quora

--

--

Pratik Butani

55k+ Reputation Holder on Stack Overflow | #FlutterDev & #AndroidDev | Team Lead @7Span | Contributor | Managing @androidschool