如何使状态和选项栏(底部)透明?
我尝试了很多想法,但它仍然是黑色和白色文本
这是我已经实现的代码:
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
...
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
systemStatusBarContrastEnforced: true,
statusBarColor: Colors.transparent,
systemNavigationBarColor: Colors.transparent,
systemNavigationBarDividerColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.light,
statusBarIconBrightness: Brightness.light));
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge,
overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
...
runApp(...)
Run Code Online (Sandbox Code Playgroud)
在我的 Material 应用程序中:
return MaterialApp.router(
theme: ThemeData(
appBarTheme: AppBarTheme(
//systemOverlayStyle: SystemUiOverlayStyle.light,
backgroundColor: Colors.transparent),
),
color: Colors.transparent,
...
Run Code Online (Sandbox Code Playgroud)
我知道 AppBar 和状态栏不一样(只是想包含它)。预先非常感谢。
更新:
我试图删除安全区域,它显然与状态栏和导航栏发生冲突。结果是这样的:
现在它仍然不是真正透明,而且底部也很混乱。有任何想法吗?