After the flutter sdk version is upgraded to 2.0 or higher, an error will be reported when running the previous code, such as:

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.

The problem above is that these packages do not support safety mode. We can add --no-sound-null-safety at runtime. Open Android Studio, and then select [Run] -->[Edit Configurations] --> [Add Additional Run args] --> [--no-sound-null-safety], as shown in the figure below.
在这里插入图片描述
Then, run it again and there is no error.


xiangzhihong
5.9k 声望15.3k 粉丝

著有《React Native移动开发实战》1,2,3、《Kotlin入门与实战》《Weex跨平台开发实战》、《Flutter跨平台开发与实战》1,2和《Android应用开发实战》