[英]Status Bar Color - Flutter
I need red status bar with white foreground for my entire app.我的整个应用程序都需要带有白色前景的红色状态栏。
I'm using flutter_statusbarcolor package for this.我为此使用了flutter_statusbarcolor package。
I did the following so far:到目前为止,我做了以下事情:
build()
of MyApp classbuild()
中添加了以下代码行 FlutterStatusbarcolor.setStatusBarColor(Colors.red[900]);
FlutterStatusbarcolor.setStatusBarWhiteForeground(true);
Result:结果:
Here is my complete code:这是我的完整代码:
import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
FlutterStatusbarcolor.setStatusBarColor(Colors.red[900]);
FlutterStatusbarcolor.setStatusBarWhiteForeground(true);
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'App Title',
home: HomeScreen(),
);
}
}
I've also tried the following:我还尝试了以下方法:
SystemChrome.setSystemUIOverlayStyle()
appBarTheme: Theme.of(context).appBarTheme.copyWith(brightness: Brightness.light)
Nothing's working.没有任何工作。 Can anyone please help me sustain the white foreground throughout the app?
谁能帮我维持整个应用程序的白色前景?
You can try this from this Doc ==> setSystemUIOverlayStyle method您可以从此 Doc ==> setSystemUIOverlayStyle 方法尝试此操作
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.red,
);
return Placeholder(); // using As your Need
}
add this:添加这个:
import 'package:flutter/services.dart'
use the code below after theme data在主题数据之后使用下面的代码
home: AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
Hope it work...希望它工作...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.