pubspec.yaml 没有下限 SDK 约束
pubspec.yaml has no lower-bound SDK constraint
我正在参加 MDC101 颤振代码实验室。我按照说明从 git 存储库中克隆了启动项目,但在克隆完成后,我执行了 flutter pub get
,它给了我以下错误。
pubspec.yaml has no lower-bound SDK constraint.
You should edit pubspec.yaml to contain an SDK constraint:
environment:
sdk: '>=2.10.0 <3.0.0'
根据错误说明,我在 pubspec.yaml
中添加了以下内容
environment:
sdk: '>=2.10.0 <3.0.0'
然后我执行了flutter pub get
,现在一切正常。
使用命令行检查你的 flutter 频道:
flutter channel
如果它在主频道然后切换到稳定频道:
flutter channel stable
如果您在 pubspec.yaml 文件包含正确的 sdk 行时仍收到此错误,请务必检查主文件夹中的子文件夹。当从 font_awesome_flutter 包中执行 flutter packages get
时,注意到会发生这种情况。原因是即使主要 pubspec.yaml 包含正确的行,但有一个令人不快的 example/pubspec.yaml
。将行添加到该文件:
environment:
sdk: ">=2.7.0 <3.0.0"
As of Dart 2.12, omitting the SDK constraint is an error. When the pubspec has no SDK constraint, pub get fails with a message like the following:
pubspec.yaml has no lower-bound SDK constraint.
You should edit pubspec.yaml to contain an SDK constraint:
(...)
For example, the following constraint says that this package works with any Dart SDK that’s version 2.10.0 or higher:
environment:
sdk: '>=2.10.0 <3.0.0'
有关详细信息,您可以查看 docs
我正在参加 MDC101 颤振代码实验室。我按照说明从 git 存储库中克隆了启动项目,但在克隆完成后,我执行了 flutter pub get
,它给了我以下错误。
pubspec.yaml has no lower-bound SDK constraint.
You should edit pubspec.yaml to contain an SDK constraint:
environment:
sdk: '>=2.10.0 <3.0.0'
根据错误说明,我在 pubspec.yaml
environment:
sdk: '>=2.10.0 <3.0.0'
然后我执行了flutter pub get
,现在一切正常。
使用命令行检查你的 flutter 频道:
flutter channel
如果它在主频道然后切换到稳定频道:
flutter channel stable
如果您在 pubspec.yaml 文件包含正确的 sdk 行时仍收到此错误,请务必检查主文件夹中的子文件夹。当从 font_awesome_flutter 包中执行 flutter packages get
时,注意到会发生这种情况。原因是即使主要 pubspec.yaml 包含正确的行,但有一个令人不快的 example/pubspec.yaml
。将行添加到该文件:
environment:
sdk: ">=2.7.0 <3.0.0"
As of Dart 2.12, omitting the SDK constraint is an error. When the pubspec has no SDK constraint, pub get fails with a message like the following:
pubspec.yaml has no lower-bound SDK constraint.
You should edit pubspec.yaml to contain an SDK constraint:
(...)
For example, the following constraint says that this package works with any Dart SDK that’s version 2.10.0 or higher:
environment:
sdk: '>=2.10.0 <3.0.0'
有关详细信息,您可以查看 docs