Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run flutter projects with different/older Dart SDK dependencies?

The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297.

Because NewsBuzz requires SDK version >=1.8.0 <2.0.0, version solving failed.

I am trying to run projects from https://startflutter.com. There are several older projects using older versions of Dart SDK or with dependencies requiring older Dart SDK version.

Is there any way to run multiple versions of Dart without downloading the older version of Dart and changing the environment variables manually?

I have gone through several StackOverflow posts and lot of Github issues without finding a proper solution.

  1. Flutter lower dart version
  2. Where is Dart's SDK located within /flutter folder?

Specifying SDK version in the pubspec.yaml does not seem to help.

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

Edit: Dart & Flutter support for Visual Studio Code docs says something about dart.sdkPaths and dart.flutterSdkPaths settings.

like image 799
Sebin Benjamin Avatar asked Dec 08 '18 13:12

Sebin Benjamin


1 Answers

I had a similar problem:

My pubspec.yaml had the following:

environment:
  sdk: ">=2.1.0 <3.0.0"

However when running flutter packages get I got the following error:

Running "flutter packages get" in xxx-app-mobile...
The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297.

Because xxx_app requires SDK version >=2.1.0 <3.0.0, version solving failed.
pub get failed (1)

I tried using the exact version name as the environment variable it did not work. I tried:

flutter upgrade
flutter clean
flutter update-packages

Received the same error when running flutter packages get I then downgraded the version requirements in the pubspec.yaml to:

environment:
  sdk: ">=2.0.0 <3.0.0"

And flutter packages get worked...

like image 99
Jason Avatar answered Oct 10 '22 11:10

Jason