我尝试使用SystemUiOverlayStyle更改我的应用程序的状态栏颜色,但没有任何改变。我也尝试过使用库和AnnotatedReagion小部件,但这是无法控制的。
@override
Widget build(BuildContext context) {
final themeColor = Provider.of<ThemeNotifier>(context);
final direction = Provider.of<Direction>(context).getAppDirection();
// FlutterStatusbarcolor.setStatusBarColor(Colors.transparent);
// SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.blue,
systemNavigationBarIconBrightness: Brightness.dark,
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.dark));
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
child: SafeArea(
child: Directionality(
textDirection: direction,
child: WillPopScope(
// ignore: missing_return
onWillPop: () {
Nav.routeReplacement(context, SignUpPage());
},
child: Scaffold(
resizeToAvoidBottomInset: false,
// backgroundColor: Colors.white,
appBar: AppBar(
leading: Container(
width: 32,
padding: const EdgeInsets.only(top: 8.0),
child: IconButton(
icon: Icon(
Icons.chevron_left,
color: themeColor.getColor(),
size: 32,
),
onPressed: () {
Navigator.pop(context);
// Navigator.pushAndRemoveUntil(
// context,
// MaterialPageRoute(builder: (context) => InitPage('')),
// (route) => false);
},
),
),
backgroundColor: Color.fromARGB(255, 252, 252, 252),
elevation: 0,
centerTitle: true,
title: Text(
"Nitrogen",
style: GoogleFonts.poppins(
fontSize: 26,
color: themeColor.getColor(),
fontWeight: FontWeight.w600,
),
),
),
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
AuthHeader(
translate('login_page.login'),
translate('login_page.existing'),
),
LoginForm(),
SizedBox(
height: 20,
),
routeLoginWidget(themeColor, context, direction),
],
),
),
),
),
),
),
);
}
我认为应用程序栏可能是造成此问题的原因,但是更改其颜色或将其完全删除后并不能解决任何问题。
有时它会闪烁为我设置的颜色,然后变为带有白色图标的完全白色或黑色背景。
有人可以告诉我我在做什么错吗?