Flutter 應用在 Android 端上啓動時會有一段很明顯的白屏現象,白屏的時長由設備的性能決定,設備性能越差,白屏時間越長。php
其實啓動白屏的問題在Android原生應用上也是一個常見問題,大體是由於從用戶點擊 Launcher Icon 到應用首頁顯示之間,Android 系統在完成應用的初始化工做,其流程以下: android
解決方案很簡單,Android原生的白屏問題能夠經過爲 Launcher Activity 設置 windowBackground 解決,而 Flutter 也是基於此辦法,同時優化了 Flutter 初始化階段的白屏問題(覆蓋一個launchView),只用兩步設置便能解決 Flutter 中白屏問題。git
<?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/background_dark" />
<!-- You can insert your own image assets here -->
<item android:bottom="84dp">
<bitmap android:src="@mipmap/launch_image" />
</item>
</layer-list>
複製代碼
github.com/zh8637688/F…github