在 main.dart 中
void main() {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.black.withOpacity(0), //top bar color
statusBarIconBrightness: Brightness.dark, //top bar icons
systemNavigationBarColor: Colors.black, //bottom bar color
systemNavigationBarIconBrightness: Brightness.light, //bottom bar icons
),
);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
//primaryColor: Color.fromRGBO(113, 201, 206, 1),
fontFamily: 'Montserrat',
textTheme: TextTheme(
headline: TextStyle(
fontSize: 40,
fontWeight: FontWeight.w500,
),
title: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 16,
),
body1: TextStyle(
fontSize: 12,
),
),
),
home: Test(),
routes: {
MainScreen.routeName: (context) => MainScreen(),
},
);
}
}
我正在使用上述代码来改变状态栏的颜色,但是statusBarIconBrightness: Brightness.dark
没有效果。
它会变成黑色,但几秒钟后又会切换回 `Brightness.light'。
问题出在哪里?
在 Android 模拟器上运行。
我不希望在 Test()
小部件中有appBar
。