当前的 Dart SDK 版本不满足空安全依赖

The current Dart SDK version does not satisfy null-safety dependences

我正在将我的项目升级到可靠的 null-safety。将版本更改为

environment:
  sdk: ">=2.12.0 <3.0.0"

然后将我的源代码转换为空安全语法。 当我 运行 我的项目时,它 运行 flutter pub get,问题发生了

[flutter_shopify] flutter pub get
Running "flutter pub get" in flutter_shopify...                 
The current Dart SDK version is 2.12.0-133.2.beta.



Because flutter_shopify requires SDK version >=2.12.0 <3.0.0, version solving failed.
pub get failed (1; Because flutter_shopify requires SDK version >=2.12.0 <3.0.0, version solving failed.)
exit code 1

我把版本改成了

environment:
  sdk: ">=2.12.0-133.2.beta <3.0.0"

但这一次,它说:

[flutter_shopify] flutter pub get
Running "flutter pub get" in flutter_shopify...                 
The current Dart SDK version is 2.12.0-133.2.beta.



Because graphql 5.0.0-nullsafety.4 requires SDK version >=2.12.0 <3.0.0 and no versions of graphql match >5.0.0-nullsafety.4 <6.0.0, graphql ^5.0.0-nullsafety.4 is forbidden.

So, because flutter_shopify depends on graphql ^5.0.0-nullsafety.4, version solving failed.
pub get failed (1; So, because flutter_shopify depends on graphql ^5.0.0-nullsafety.4, version solving failed.)
exit code 1

我也是一头雾水,我知道Dart SDK的版本是跟在flutter SDK之后的,但是现在对依赖不满意

这样的话,请问有什么办法可以将我的Dart SDK升级到高于flutter SDK holding的版本吗?

这是flutter doctor

[✓] Flutter (Channel beta, 2.2.0-10.2.pre, on macOS 11.3 20E232 darwin-x64, locale en-VN)
    • Flutter version 2.2.0-10.2.pre at /.../flutter
    • Framework revision b5017bf8de (8 days ago), 2021-04-28 17:09:53 -0700
    • Engine revision 91ed51e05c
    • Dart version 2.13.0 (build 2.13.0-211.13.beta)

请帮忙!非常感谢你们!

我在 Visual Studio 代码 settings.json 中发现了问题,其中 dart.flutterSdkPath 设置不正确到另一个文件夹。

更改 flutter channel stableflutter upgrade 已经可以解决空安全问题。