Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart SDK version mismatch while installing build_runner

I'm trying to add build_runner: ^1.10.2 to dev_dependencies in the pubspec.yaml file, but I am getting the following error:

The current Dart SDK version is 2.9.0.

Because project_name depends on build_runner >=1.10.2 which requires SDK version >=2.10.0-0.0 <3.0.0, version solving failed.
pub get failed (1; Because project_name depends on build_runner >=1.10.2 which requires SDK version >=2.10.0-0.0 <3.0.0, version solving failed.)

I checked the dart website and the latest version of Dart SDK is 2.9.0 while 2.10 is still in dev.

Here's my flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.20.1, on Microsoft Windows [Version 10.0.18362.959], locale en-IN)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 4.0)
[√] VS Code, 64-bit edition (version 1.39.2)
[√] Connected device (1 available)

• No issues found!

like image 512
Michael Hathi Avatar asked Aug 08 '20 12:08

Michael Hathi


People also ask

How do I manually install dart sdk?

Open Android Studio and click on Configure. Then, select Plugins. From the resulting screen, click on Flutter and click on Install. Click on Accept and then Yes to install the Dart plugin.


Video Answer


3 Answers

As of September 28, 2020 the latest version of Flutter on stable channel no longer has this issue.

Use these commands to upgrade.

flutter channel stable
flutter upgrade
like image 145
Michael Hathi Avatar answered Oct 20 '22 09:10

Michael Hathi


This is an issue with the latest releases of dart, analyzer, and flutter creating conflicts with each other, which you can read more about at this Github issue. There likely is no real issue with your configuration.

A temporary solution that I've seen is to use a dependency override of the analyzer:

dev_dependencies:
  build_runner: ^1.10.0

dependency_overrides:
  analyzer: 0.39.14
like image 29
Christopher Moore Avatar answered Oct 20 '22 07:10

Christopher Moore


I encountered this problem after doing some cleaning up of my directories and having downloaded/installed the latest flutter. Bam. Then I realised that version of flutter sits by default on channel stable. After switching to master, it solved my problem, i.e.:

flutter channel master
flutter upgrade
like image 8
Johan Witters Avatar answered Oct 20 '22 09:10

Johan Witters