簡體   English   中英

狀態欄不會改變 flutter 中的背景顏色

[英]status bar doesn't change background color in flutter

我有兩個頁面,第一個頁面有白色狀態欄,第二個頁面有灰色狀態欄,但是當我從一個頁面移動到另一個頁面時,第二個頁面采用第一個狀態欄顏色?

注意:當我從主 function 運行第二頁時,它采用正確的顏色

我將它用於狀態欄:

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
        statusBarColor: Color(0xffF6F6F6), 
        statusBarBrightness: Brightness.dark 
));

這是什么原因?

試試這個: -

在 main.dart class 中用以下代碼包裝您的 MaterialApp:-

AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle(
        statusBarColor: Colors.transparent, //set as per your  status bar color
        systemNavigationBarColor: Colors.black, //set as per your navigation bar color
        statusBarIconBrightness: Brightness.dark, //set as per your status bar icons' color
        systemNavigationBarIconBrightness: Brightness.dark,
      ),
      child: MaterialApp(

如果您想更改整個應用程序的應用欄顏色,請在下面嘗試

theme: Theme.of(context).copyWith(
            appBarTheme: Theme.of(context)
                .appBarTheme
                .copyWith(brightness: Brightness.light),
        ),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM