I want to enable the light mode for the status and navigation bar in Flutter Android starting from launch, so that the icons are dark. I can change the background color of both in the Main Activity, but setting to light mode with window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
seems to have no effect and the icons remain white.
Watch it here:
The code looks like this:
styles.xml
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowDisablePreview">true</item>
</style>
MainActivity.kt
class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (Build.VERSION.SDK_INT >= 26) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION or WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.statusBarColor = Color.parseColor("#ffffff")
window.navigationBarColor = Color.parseColor("#ffffff")
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
if (Build.VERSION.SDK_INT >= 28) {
window.navigationBarDividerColor = Color.parseColor("#eeeeee")
}
}
}
I know that we can set it with the Flutter API with SystemChrome
as answered here, but that doesn't affect the status and navigation bar during launch.
Watch it here: