你如何为Flutter应用添加启动屏?它应该在任何其他内容加载之前就能够加载和显示。目前,Scaffold(home:X)小部件加载之前会有短暂的闪烁。
你如何为Flutter应用添加启动屏?它应该在任何其他内容加载之前就能够加载和显示。目前,Scaffold(home:X)小部件加载之前会有短暂的闪烁。
对于那些像我一样按照步骤操作但仍然无法使其正常工作的人...
请注意,如果您有一个drawable-v21文件夹,您需要将代码从drawable文件夹中的launch_background.xml复制到drawable-v21文件夹中的launch_background.xml。
我的项目不喜欢android:src="@mipmap/launch" />
因此我使用了android:src="@drawable/launch" />
Flutter.dev已经给出了最好的答案,这不是一个错误也不是一个问题,只是配置问题。 花点时间阅读一下,一切都会解决的。祝大家有美好的一天。
https://flutter.dev/docs/development/ui/advanced/splash-screen
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <item android:drawable="@android:color/white" /> -->
<item android:drawable="@color/custom_color" /> <!-- // Modified \\ -->
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
SplashScreen(
seconds: 3,
navigateAfterSeconds: new MyApp(),
// title: new Text(
// 'Welcome In SplashScreen',
// style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
// ),
image: new Image.network('https://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/Tesla_Motors.svg/1200px-Tesla_Motors.svg.png'),
backgroundColor: Colors.white,
styleTextUnderTheLoader: new TextStyle(),
photoSize: 150.0,
loaderColor: Colors.black),
),
);