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

7,668

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...

Share:
7,668
Sebin Benjamin
Author by

Sebin Benjamin

Solving the mysteries behind code.

Updated on December 08, 2022

Comments

  • Sebin Benjamin
    Sebin Benjamin over 1 year
    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.

    • Günter Zöchbauer
      Günter Zöchbauer over 5 years
      Clone and update NewsBuzz to work with current Dart/Flutter versions. Ideally make a Pull Request afterwards to the original package.
    • Sebin Benjamin
      Sebin Benjamin over 5 years
      I don't wish to update every flutter app I come across. I was hoping to run it isolated without having to upgrade/downgrade my flutter installation. Like we do with angular/ionic apps or NPM (npmjs.com).
  •   vrnvorona
    vrnvorona about 2 years
    Unless you work on pet project, you can't just upgrade in production app.