[英]How to use the flutter native splash screen
I am facing trouble using the flutter native splash screen.A blank screen appears when i tried to use the flutter_native_splash package https://pub.dev/packages/flutter_native_splash我在使用 flutter native splash screen 时遇到问题。当我尝试使用 flutter_native_splash 包时出现空白屏幕https://pub.dev/packages/flutter_native_splash
You can create native splash screen for both (android, iOS) platform manually to follow the doc ( https://docs.flutter.dev/development/ui/advanced/splash-screen ) but I will recommend you to use flutter_native_splash
plugin cause it will save your time and less opportunity of mistakes.您可以手动为两个(android、iOS)平台创建原生启动画面以遵循文档( https://docs.flutter.dev/development/ui/advanced/splash-screen ),但我建议您使用
flutter_native_splash
插件,因为它将节省您的时间并减少出错的机会。
Create a new assets and logos folder in your root project path and place your splash_screen_logo.png
like this [project_name]/assets/logos/splash_screen_logo.png
在您的根项目路径中创建一个新的资产和徽标文件夹,并将您的
splash_screen_logo.png
像这样[project_name]/assets/logos/splash_screen_logo.png
Add flutter_native_splash: ^2.1.1
at dev_dependencies
in pubspec.yaml
(please replace ^2.1.1 version
with the latest one)在
dev_dependencies
中的pubspec.yaml
添加flutter_native_splash: ^2.1.1
(请将^2.1.1 version
替换为最新版本)
dev_dependencies:
flutter_test:
sdk: flutter
flutter_native_splash: ^2.1.1
Paste this below code in your pubspec.yaml
and change the color and image asset path将下面的代码粘贴到您的
pubspec.yaml
中并更改颜色和图像资产路径
flutter_native_splash:
color: "#071b5d"
image: assets/logos/splash_screen_logo.png
android: true
ios: true
Finally in your project path terminal, run this command: flutter pub run flutter_native_splash:create
and it will generate native splash screen for both android and iOS.最后在您的项目路径终端中,运行此命令:
flutter pub run flutter_native_splash:create
它将为 Android 和 iOS 生成原生启动画面。
The actual and perfect way is not to add a page or use a plugin, you can even do it natively by this method: Go to => andoid > app > main > res > drawable > in this folder you can see a file called lauch_background open it,真正完美的方法是不添加页面或使用插件,你甚至可以通过这种方法原生地完成:转到 => andoid > app > main > res > drawable > 在这个文件夹中你可以看到一个名为 lauch_background 的文件打开它,
<?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" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="fill"
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>
add your image in the folder and rename the image file name to ic_launcher.在文件夹中添加您的图像并将图像文件名重命名为 ic_launcher。 Also uncomment the commented code in the file.
同时取消注释文件中的注释代码。
refer this example for you native splash screen https://www.codegrepper.com/code-examples/whatever/flutter+native+splash+screen为您参考此示例本机启动画面https://www.codegrepper.com/code-examples/whatever/flutter+native+splash+screen
this is the right code, the right indentation matters这是正确的代码,正确的缩进很重要
flutter_native_splash: ^2.2.16
flutter_native_splash: flutter_native_splash:
color: "#004ab9" images: assets/finviobackground.png android: true ios: true颜色:“#004ab9” 图片:assets/finviobackground.png android: true ios: true
Two Packages are Needed If you want to Add a Native Flutter Splash screen and Change App Icon using Easy Method如果你想使用 Easy 方法添加原生 Flutter 启动画面和更改应用程序图标,则需要两个包
Flutter native splash screen and App icon change - Easy Method Flutter原生启动画面和应用程序图标更改-简单方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.