我应该担心 Flutter 和 Dart 版本不同吗?

Should I worry about Flutter and Dart version being different?

Flutter 使用 dart-lang SDK(和可执行文件)。因此,当我想查看我使用的是哪个版本时,我 运行 得到以下内容:

颤振

flutter --version

输出

Flutter 1.23.0-18.1.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 198df796aa (7 days ago) • 2020-10-15 12:04:33 -0700
Engine • revision 1d12d82d9c
Tools • Dart 2.11.0 (build 2.11.0-213.1.beta)

版本:2.11.0

飞镖

但是当我检查我机器的 dart 版本时。我看到了一些不同的东西..

dart --version

输出

Dart SDK version: 2.10.2 (stable) (Tue Oct 13 15:50:27 2020 +0200) on "macos_x64"

版本:2.10.2


如何确保在 dart 工具和 flutter 之间始终使用相同的 dart-sdk 和可执行文件?管理这两个工具是什么?我是否应该担心 Flutter 和 Dart 版本不同 (edit)?

Flutter 版本和 Dart 版本不必相同。从here, the latest Dart SDK version is 2.10.0. But there are lots of newer versions in Flutter as in here可以看出。 Dart 在他们的文档中有一个版本说明:

As of Flutter 1.21, the Flutter SDK includes the full Dart SDK. This site’s documentation and examples use version 2.10.0 of the Dart SDK.

如果之前单独安装过dart sdk,直接删除即可,Flutter自带的dart sdk会自动使用

找到安装文件夹which dart

如果不在flutter SDK文件夹中

然后rm -r文件夹

您不必担心,但更重要的是,这两个版本 是为彼此构建的。

例如,当您安装旧版本的 Flutter 时,将使用的 Dart 版本将不是最新的版本的 Dart,而是已发布的版本与您使用的 Flutter 大致相同。

我在我的问题/ GitHub 问题中学到了这一点,选择 Flutter 使用的特定 Dart 版本 .

Flutter is tightly coupled to Dart, so you can't mix and match versions. If you really wanted to run a specific version of Dart that it wasn't built with you would need to fork the framework and the engine and custom-build your own combination, which would almost certainly include lots of changes to make them compatible. Stuart Morgan, Flutter team