如何使用不同/较旧的Dart SDK依赖项运行Flutter项目?

时间:2018-12-08 13:04:08

标签: dart flutter flutter-dependencies dart-sdk

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.

我正在尝试从https://startflutter.com运行项目。有多个使用较旧版本的Dart SDK的较旧项目,或者具有需要较旧Dart SDK版本的依赖项。

是否可以运行多个版本的Dart,而无需下载较旧版本的Dart并手动更改环境变量?

我经历了数个StackOverflow帖子和许多Github问题,但没有找到合适的解决方案。

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

pubspec.yaml中指定SDK版本似乎无济于事。

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

编辑:Dart & Flutter support for Visual Studio Code个文档对dart.sdkPathsdart.flutterSdkPaths设置进​​行了说明。

2 个答案:

答案 0 :(得分:3)

我有一个类似的问题:

我的pubspec.yaml具有以下内容:

environment:
  sdk: ">=2.1.0 <3.0.0"

但是在运行flutter packages get时出现以下错误:

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)

我尝试使用确切的版本名称作为无效的环境变量。我尝试过:

flutter upgrade
flutter clean
flutter update-packages

运行flutter packages get时收到相同的错误 然后,我将pubspec.yaml中的版本要求降级为:

environment:
  sdk: ">=2.0.0 <3.0.0"

flutter packages get工作了...

答案 1 :(得分:0)

只需将fld sdk更新到最新版本。