Flutter:安装依赖报错doesn‘t support null safety

项目中需要引用http依赖,在pubspec.yaml文件中添加如下信息:

Flutter:安装依赖报错doesn‘t support null safety

当同步时,报错信息如下:

[myflutter] flutter pub upgrade

Resolving dependencies…

The current Dart SDK version is 3.1.3.

Because myflutter depends on http >=0.2.8+2 <0.13.0-nullsafety.0 which doesn't support null safety, version solving failed.

The lower bound of “sdk: ‘=2.0.0-dev.61.0 <3.0.0'" must be 2.12.0 or higher to enable null safety.

For details, see https://dart.dev/null-safety

 

You can try the following suggestion to make the pubspec resolve:

* Try upgrading your constraint on http: flutter pub add http:^1.1.0

exit code 1

 大概的意思是,你当前的系统sdk版本是3.1.3,是支持空对象的安全技术,而你要引入的http的版本小于0.13.0,不支持空安全,所以两个不匹配,报错。

在这个区间的http包(http >=0.2.8+2 <0.13.0)不支持空安全

所以我们把引用的http包的版本号提升一下即可。

Flutter:安装依赖报错doesn‘t support null safety

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/ebe7649f59.html