我试图将启动屏幕添加到我的 flutter 应用程序中,但是当我将“flutter_native_splash”依赖项添加到我的 pubspec.yaml 文件中时,我无法运行 android 模拟器。当我按下“开始调试”时,没有任何反应。调试控制台仅打印“在调试模式下在 sdk gphone64 x86 64 上启动 lib\main.dart...”,然后停止启动过程。我尝试将其他包添加到我的 pubspec.yaml 文件中,并且它与其他包一起工作得很好。
另外,我检查了Flutter Doctor。一切看起来都很好。尝试了 flutter clean 也没有任何改变。当我的 pubspec.yaml 文件中存在此依赖项时,我无法在模拟器中运行我的应用程序。
第1步:添加带有路径的图像飞溅:
assets/images/img_splash.png
第 2 步: 在
pubspec.yaml
中声明启动图像
flutter:
uses-material-design: true
assets:
- assets/icons/
- assets/locales/
- assets/images/
flutter_native_splash:
image: assets/images/img_splash.png
color: "0084FF"
fill: true
第3步:在根项目的终端中运行命令
dart run flutter_native_splash:create
希望有帮助!