如何在AppBar不存在时设置状态栏 colored颜色 .

我试过这个,但不管用.

Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
    return new Scaffold(
        body: new Container(
        color: UniQueryColors.colorBackground,
        child: new ListView.builder(
           itemCount: 7,
           itemBuilder: (BuildContext context, int index){
             if (index == 0){
               return addTopInfoSection();
             }
           },
        ),
       ),
    );
}

Output look like this:

enter image description here

推荐答案

首先,进口services个包装:

import 'package:flutter/services.dart';

下一步,只需将其放入应用程序的build function中:

SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
  statusBarColor: Colors.blue, //or set color with: Color(0xFF0000FF)
));

此外,您还可以设置有用的属性,如:statusBarIconBrightnesssystemNavigationBarColorsystemNavigationBarDividerColor


如果你喜欢做同样的事情的flutter/widget种方式,考虑使用AnnotatedRegion<SystemUiOverlayStyle>个小部件.

可以将value:属性设置为包含如上所示相同属性的SystemUiOverlayStyle()对象.


For more infos, head over to the 100

Flutter相关问答推荐

ListTile未正确显示在flutter中

如何使一个悬浮的appbar在flutter?

如何将Xpriter代码页更改为代码页27?

blocTest错误:没有从`when()`中调用方法存根

如何实现Flutter 梳理机图像的小量移动

Flex ListView用于可滚动和响应的页面

如何在不注销的情况下刷新Firebase身份验证用户

在创建显示此错误的Flutter 深度链接时

导航回上一页会将我带回Ffltter应用程序中的登录页面

在flutter中实现类似3D的可滚动堆叠分页列表

Flutter 附近的连接

Flutter Web Dio XMLHttpRequest 上传大文件时出错

Firebase Auth - 有没有办法为新用户预先生成 UID?

我在手机上找不到我的 Flutter 应用缓存数据

如何防止键盘将内容向上推?

setState 方法有时有效,有时无效

graphql_flutter 错误:非抽象类GraphQLWebSocketChannel缺少实现

有什么办法可以消除Flutter 中的传递依赖?

如何在Flutter 中将列表的模型类型转换为数组?

如何在Flutter 的 initState 中初始化 Firestore 查询