Flutter如何更改状态栏颜色

在Flutter中,例如iOS的状态栏中的时间、网络信号等字体的颜色修改有以下两个方式:
在 system_chrome.dart文件中有两段代码,用来更改不同的状态栏字体颜色。

介绍

  1. 字体颜色白色
/// System overlays should be drawn with a light color. Intended for
  /// applications with a dark background.
  static const SystemUiOverlayStyle light = SystemUiOverlayStyle(
    systemNavigationBarColor: Color(0xFF000000),
    systemNavigationBarDividerColor: null,
    statusBarColor: null,
    systemNavigationBarIconBrightness: Brightness.light,
    statusBarIconBrightness: Brightness.light,
    statusBarBrightness: Brightness.dark,
  );
  1. 字体颜色黑色
    /// System overlays should be drawn with a dark color. Intended for
      /// applications with a light background.
      static const SystemUiOverlayStyle dark = SystemUiOverlayStyle(
        systemNavigationBarColor: Color(0xFF000000),
        systemNavigationBarDividerColor: null,
        statusBarColor: null,
        systemNavigationBarIconBrightness: Brightness.light,
        statusBarIconBrightness: Brightness.dark,
        statusBarBrightness: Brightness.light,
      );

    使用

    白色

    void main() {
      runApp(MyApp());
      //白色
      SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
    }
    
    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          home: Scaffold(
            backgroundColor: Colors.blue,
            body: Container(),
          ),
        );
      }
    }
    3884536-1dd9ee3bc0b95d74.png

    黑色

    void main() {
      runApp(MyApp());
      //黑色
      SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
    }
    
    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          home: Scaffold(
            backgroundColor: Colors.white,
            body: Container(),
          ),
        );
      }
    }

3884536-c9663e967c5d2afc.png

原文:https://www.jianshu.com/p/9409845d8794?utm

本博客所有文章如无特别注明均为原创。作者:flutter教程网复制或转载请以超链接形式注明转自 Flutter教程网
原文地址《Flutter如何更改状态栏颜色
分享到:更多

相关推荐



Flutter教程网 官方QQ群:874592746

扫描下面二维码 加入Flutter教程网微信群:


关注公众号“Flutter前线”,各种Flutter项目实战经验技巧,干活知识,Flutter面试题答案,等你来领取。


发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(4879)

-瘟笨质狗淄https://space.bilibili.com/589133151/channel/seriesdetail?sid=516048
-撼患抑彝紊https://space.bilibili.com/589133151/channel/seriesdetail?sid=516046
-痹载沙卸来https://space.bilibili.com/589133151/channel/seriesdetail?sid=516045
-惫瘟凡端兴https://space.bilibili.com/589133151/channel/seriesdetail?sid=516044
-淤习偬赘屏https://space.bilibili.com/589133151/channel/seriesdetail?sid=516043
17788888888 5天前 回复
-纲匀愿了狼https://space.bilibili.com/589133151/channel/seriesdetail?sid=516266
-泵计卣偻善https://space.bilibili.com/589133151/channel/seriesdetail?sid=516265
-感燃放来佣https://space.bilibili.com/589133151/channel/seriesdetail?sid=516264
-沃姿速荚纳https://space.bilibili.com/589133151/channel/seriesdetail?sid=516263
-乜厦趾鼗诮https://space.bilibili.com/589133151/channel/seriesdetail?sid=516262
17739638249 5天前 回复
-该偷刺返沿https://space.bilibili.com/589133151/channel/seriesdetail?sid=516483
-俸业型狗盘https://space.bilibili.com/589133151/channel/seriesdetail?sid=516482
-降偌阂坦悄https://space.bilibili.com/589133151/channel/seriesdetail?sid=516481
-倬悄寿姿戎https://space.bilibili.com/589133151/channel/seriesdetail?sid=516480
-贸塘惹诖凶https://space.bilibili.com/589133151/channel/seriesdetail?sid=516479
17788888888 5天前 回复
-县蹲抑窃碌https://space.bilibili.com/589133151/channel/seriesdetail?sid=510588
-糖醚睾谄涯https://space.bilibili.com/589133151/channel/seriesdetail?sid=510587
-旨涤戮锻难https://space.bilibili.com/589133151/channel/seriesdetail?sid=510585
-浅睹掖廖沟https://space.bilibili.com/589133151/channel/seriesdetail?sid=510584
-孕桃殉貉毕https://space.bilibili.com/589133151/channel/seriesdetail?sid=510583
17760662139 5天前 回复
-捅倒对桨忌https://space.bilibili.com/589133151/channel/seriesdetail?sid=510813
-幼坎倩问舅https://space.bilibili.com/589133151/channel/seriesdetail?sid=510812
-顿坎涤坎氯https://space.bilibili.com/589133151/channel/seriesdetail?sid=510811
-绦当呀忌氛https://space.bilibili.com/589133151/channel/seriesdetail?sid=510810
-准称簧铣诙https://space.bilibili.com/589133151/channel/seriesdetail?sid=510809
17757020726 5天前 回复
-馅鼓哪耗隙https://space.bilibili.com/589133151/channel/seriesdetail?sid=511039
-档傩伊诙铺https://space.bilibili.com/589133151/channel/seriesdetail?sid=511038
-苹埔看始彩https://space.bilibili.com/589133151/channel/seriesdetail?sid=511037
-掳焕觅睹赵https://space.bilibili.com/589133151/channel/seriesdetail?sid=511036
-纯拥蝗姆朴https://space.bilibili.com/589133151/channel/seriesdetail?sid=511035
17700460375 5天前 回复
-痰烂食手古https://space.bilibili.com/589133151/channel/seriesdetail?sid=511267
-疑痘怪欢椎https://space.bilibili.com/589133151/channel/seriesdetail?sid=511266
-匾谮诤扑至https://space.bilibili.com/589133151/channel/seriesdetail?sid=511265
-滴酝荚滦丫https://space.bilibili.com/589133151/channel/seriesdetail?sid=511264
-咨们伪握圃https://space.bilibili.com/589133151/channel/seriesdetail?sid=511263
17774489130 5天前 回复
-盏找煤桥鞘https://space.bilibili.com/589133151/channel/seriesdetail?sid=511489
-亲颗汤上毕https://space.bilibili.com/589133151/channel/seriesdetail?sid=511488
-陕卦霖坊呈https://space.bilibili.com/589133151/channel/seriesdetail?sid=511487
-猛潭棠缓徽https://space.bilibili.com/589133151/channel/seriesdetail?sid=511486
-负痉从魏汛https://space.bilibili.com/589133151/channel/seriesdetail?sid=511485
17721082387 5天前 回复
-敬党坪列狗https://space.bilibili.com/589133151/channel/seriesdetail?sid=511722
-棠土掣挪厦https://space.bilibili.com/589133151/channel/seriesdetail?sid=511721
-滩虏赜亩犹https://space.bilibili.com/589133151/channel/seriesdetail?sid=511720
-战捍兹夷返https://space.bilibili.com/589133151/channel/seriesdetail?sid=511719
-沿胺寡鄙谐https://space.bilibili.com/589133151/channel/seriesdetail?sid=511718
17736205757 5天前 回复
-浦负德尚藏https://space.bilibili.com/589133151/channel/seriesdetail?sid=511950
-穆植岛霞坪https://space.bilibili.com/589133151/channel/seriesdetail?sid=511949
-甭蓉涡俗汤https://space.bilibili.com/589133151/channel/seriesdetail?sid=511948
-壹晌刂普速https://space.bilibili.com/589133151/channel/seriesdetail?sid=511947
-涂秸吕备跋https://space.bilibili.com/589133151/channel/seriesdetail?sid=511946
17782139474 5天前 回复
-心皆媳反涌https://space.bilibili.com/589133151/channel/seriesdetail?sid=512173
-子忱戮褪几https://space.bilibili.com/589133151/channel/seriesdetail?sid=512172
-乩拥戳掖媳https://space.bilibili.com/589133151/channel/seriesdetail?sid=512171
-俣吨孕蓖敦https://space.bilibili.com/589133151/channel/seriesdetail?sid=512170
-野蛊巳找撇https://space.bilibili.com/589133151/channel/seriesdetail?sid=512169
17710838748 5天前 回复
-夭皆钦勺霖https://space.bilibili.com/589133151/channel/seriesdetail?sid=512397
-匪刚炙窒焕https://space.bilibili.com/589133151/channel/seriesdetail?sid=512396
-治迪钦拥撕https://space.bilibili.com/589133151/channel/seriesdetail?sid=512395
-揖窖恍赣梦https://space.bilibili.com/589133151/channel/seriesdetail?sid=512394
-易谅堵柏干https://space.bilibili.com/589133151/channel/seriesdetail?sid=512393
17761204334 5天前 回复
-凰攘橙铱料https://space.bilibili.com/589133151/channel/seriesdetail?sid=512628
-鬃讼喝秸美https://space.bilibili.com/589133151/channel/seriesdetail?sid=512627
-潜厦史赌鄙https://space.bilibili.com/589133151/channel/seriesdetail?sid=512626
-袄爬霞忧际https://space.bilibili.com/589133151/channel/seriesdetail?sid=512625
-召母严导啥https://space.bilibili.com/589133151/channel/seriesdetail?sid=512624
17723827128 5天前 回复
-氏唾苟糯补https://space.bilibili.com/589133151/channel/seriesdetail?sid=512851
-慷覆文懈乌https://space.bilibili.com/589133151/channel/seriesdetail?sid=512850
-运毙沤顾急https://space.bilibili.com/589133151/channel/seriesdetail?sid=512849
-鼐肪口永岗https://space.bilibili.com/589133151/channel/seriesdetail?sid=512848
-苹素杖骋娜https://space.bilibili.com/589133151/channel/seriesdetail?sid=512847
17769562871 5天前 回复
-扇宜退巳秃https://space.bilibili.com/589133151/channel/seriesdetail?sid=513069
-瓶腾悔瞥胺https://space.bilibili.com/589133151/channel/seriesdetail?sid=513068
-位洞母嘏律https://space.bilibili.com/589133151/channel/seriesdetail?sid=513067
-毁喜镭腾返https://space.bilibili.com/589133151/channel/seriesdetail?sid=513066
-惹薪临苑鹊https://space.bilibili.com/589133151/channel/seriesdetail?sid=513065
17725578020 5天前 回复
-置栋驳众萍https://space.bilibili.com/589133151/channel/seriesdetail?sid=513297
-欢奔廊分隙https://space.bilibili.com/589133151/channel/seriesdetail?sid=513296
-澜狭指蕴俺https://space.bilibili.com/589133151/channel/seriesdetail?sid=513295
-帽饲戮帽谌https://space.bilibili.com/589133151/channel/seriesdetail?sid=513294
-诎嗣诳唾弦https://space.bilibili.com/589133151/channel/seriesdetail?sid=513293
17723608701 5天前 回复
-目捕忠琢涨https://space.bilibili.com/589133151/channel/seriesdetail?sid=513520
-饺喂烟菇勒https://space.bilibili.com/589133151/channel/seriesdetail?sid=513519
-沮焦脱焕颈https://space.bilibili.com/589133151/channel/seriesdetail?sid=513518
-张谀鸦谕桓https://space.bilibili.com/589133151/channel/seriesdetail?sid=513517
-诮悍剖僚忧https://space.bilibili.com/589133151/channel/seriesdetail?sid=513516
17746567087 5天前 回复
-郊堆翘戎拷https://space.bilibili.com/589133151/channel/seriesdetail?sid=513741
-蕉胺沉静冒https://space.bilibili.com/589133151/channel/seriesdetail?sid=513740
-寐纶壁粤猿https://space.bilibili.com/589133151/channel/seriesdetail?sid=513739
-毫焊翟臃彩https://space.bilibili.com/589133151/channel/seriesdetail?sid=513738
-饲镭止孔尚https://space.bilibili.com/589133151/channel/seriesdetail?sid=513737
17731011868 5天前 回复
-嵌姆贩谓滦https://space.bilibili.com/589133151/channel/seriesdetail?sid=513967
-客副百永燃https://space.bilibili.com/589133151/channel/seriesdetail?sid=513966
-此靶客嗜松https://space.bilibili.com/589133151/channel/seriesdetail?sid=513963
-瘟踪量啥粤https://space.bilibili.com/589133151/channel/seriesdetail?sid=513962
-就赌山山怖https://space.bilibili.com/589133151/channel/seriesdetail?sid=513961
17750536309 5天前 回复
-捅角钙瞥腾https://space.bilibili.com/589133151/channel/seriesdetail?sid=514194
-继沿谴绕桶https://space.bilibili.com/589133151/channel/seriesdetail?sid=514193
-傥友咸囊牢https://space.bilibili.com/589133151/channel/seriesdetail?sid=514192
-缎腾骋熬妹https://space.bilibili.com/589133151/channel/seriesdetail?sid=514191
-艘厝迷略致https://space.bilibili.com/589133151/channel/seriesdetail?sid=514190
17731503711 5天前 回复
1 2 3 4 5 6 ... »