简体   繁体   English

flutter原生启动画面的使用方法

[英]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.同时取消注释文件中的注释代码。

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 启动画面和更改应用程序图标,则需要两个包

  1. flutter_native_splash 2.2.16 flutter_native_splash 2.2.16
  2. flutter_launcher_icons flutter_launcher_icons

Flutter native splash screen and App icon change - Easy Method Flutter原生启动画面和应用程序图标更改-简单方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用户登录时使用flutter_native_splash时如何跳过启动画面 - How to skip the splash screen when use flutter_native_splash while user is logged In 如何在 Flutter 中获取原生启动画面? - How to get Native Splash Screen in Flutter? 如何从flutter应用程序中删除本机启动画面? - How to remove native splash screen from flutter app? 身份验证加载时如何显示颤动的原生闪屏? - How to show flutter native splash screen when authentication loading? 如何在颤动中更改原生闪屏的状态栏颜色? - How to change status bar color of native splash screen in flutter? 如何在 flutter 中使用 flutter_native_splash package 更改启动画面的时间? - How to change time for splash screen using flutter_native_splash package in flutter? flutter 中,如何去掉原生启动画面和主画面之间的默认淡入淡出过渡? (仅使用本机启动画面) - How to remove the default fade transition between the native splash screen and the home screen in flutter? (Using native splash screen only) 如何使用 Flutter_native_splash 在初始屏幕底部添加文本 - How to add text at bottom in splash screen using Flutter_native_splash Flutter中需要实现Native闪屏2秒 - Need to implement Native splash screen for 2 seconds in flutter Flutter:使用原生启动画面更好吗? - Flutter : Is using Native Splash Screen better?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM