[英]Why I cant't change the status bar color to white in flutter
// ignore_for_file: constant_identifier_names
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:myapp/config/app_config.dart';
import 'package:myapp/themes/themes.dart';
import 'package:url_strategy/url_strategy.dart';
Future main() async {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Colors.white, // status bar color
statusBarBrightness: Brightness.dark));
WidgetsFlutterBinding.ensureInitialized();
const ENV = String.fromEnvironment('ENV', defaultValue: 'dev');
await AppConfig.configEnv(ENV);
setPathUrlStrategy();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
child: GetMaterialApp(
theme: theme(),
debugShowCheckedModeBanner: false,
title: "Myapp",
home: const HomeScreen()),
);
}
}
I tried to change the color to something else then it works but when I the change color to whit it is not working.is ther any problem in my code.我尝试将颜色更改为其他颜色然后它可以工作但是当我将颜色更改为白色时它不起作用。我的代码中有任何问题。
please try this请试试这个
SystemUiOverlayStyle
.dark
.copyWith(
statusBarColor: Colors.white
)),
Please try this code I edited.请尝试我编辑的这段代码。
Future main() async {
runApp(const MyApp());
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
systemNavigationBarColor: Colors.black,
statusBarColor: Colors.white,
statusBarBrightness: Brightness.dark,
statusBarIconBrightness: Brightness.dark
));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.