简体   繁体   English

为什么状态栏颜色比 flutter-android 中的应用栏颜色略深?

[英]Why status bar color is slightly dark from appbar color in flutter-android?

What i had tried,我试过的,

https://sarunw.com/posts/how-to-change-status-bar-text-color-in-flutter/

I tried every solution from above blog, but i cant find proper solution.我尝试了上面博客中的所有解决方案,但找不到合适的解决方案。

In this below image status bar is slightly dark blue I want to same color as appbar color在下面的图像状态栏中,状态栏略带深蓝色,我想使用与应用栏颜色相同的颜色

Statusbar Color 状态栏颜色

So by default the Android navigation bar sits on top of the flutter app AppBar and has some transparency.所以默认情况下,Android 导航栏位于 flutter 应用程序 AppBar 的顶部,并且具有一定的透明度。 You are on the right track with editing the status bar.您在编辑状态栏方面走在正确的轨道上。 By default it looks something like this:默认情况下,它看起来像这样: 在此处输入图像描述

You can edit the status bar color manually by adding a SystemChrome.setSystemUIOverlayStyle to the build function of the root widget:您可以通过将SystemChrome.setSystemUIOverlayStyle添加到根小部件的build function 来手动编辑状态栏颜色:

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
      statusBarColor: Colors.blue,
    ));
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

You will need to import services.dart as well:您还需要导入services.dart

import 'package:flutter/services.dart';

But then your status bar/app bar should look like this:但是你的状态栏/应用栏应该是这样的: 在此处输入图像描述

There are other properties you can play with here, check out the API documentation for the SystemUiOverlayStyle class您可以在此处使用其他属性,请查看API SystemUiOverlayStyle class 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM