遇到問題 Cannot run with sound null safety
flutter sdk 版本升級到2.0或者更高的版本后,運行之前的代碼會報錯,比如:
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- 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
解決方案:
run
flutter run --no-sound-null-safety
build
flutter build apk --no-sound-null-safety