flutter debug&release 已解决 Error: Cannot run with sound null safety, because the following depende...

flutter sdk 版本升级到2.0或者更高的版本后就发现运行时会报错:

Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:loading_indicator_view
 - package:flutter_swiper
 - package:flutter_page_indicator
 - package:transformer_page_view

For solutions, see https://dart.dev/go/unsound-null-safety


FAILURE: Build failed with an exception.

也就是说以上有些包不支持 safety模式。

解决方案:--no-sound-null-safety

  1. 方案一:

通过命令行运行:

  • run (debug运行)
    flutter run --no-sound-null-safety
  • build (打包apk)
    flutter build apk --no-sound-null-safety
  1. 方案二:
  • 也可以在Android studio中设置运行配置。首先打开Edit Configurations 页面;
截屏2021-08-11 上午12.06.16.png
  • 然后在Additional run args 这行键入一下命令:
--no-sound-null-safety
截屏2021-10-24 下午1.05.34.png

你可能感兴趣的:(flutter debug&release 已解决 Error: Cannot run with sound null safety, because the following depende...)