小编Cas*_* Bm的帖子

Flutter状态栏透明

在此输入图像描述

如何使状态和选项栏(底部)透明?

我尝试了很多想法,但它仍然是黑色和白色文本

这是我已经实现的代码:

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 和状态栏不一样(只是想包含它)。预先非常感谢。

更新:

我试图删除安全区域,它显然与状态栏和导航栏发生冲突。结果是这样的:

在此输入图像描述

现在它仍然不是真正透明,而且底部也很混乱。有任何想法吗?

android statusbar dart android-statusbar flutter

6
推荐指数
1
解决办法
3223
查看次数

标签 统计

android ×1

android-statusbar ×1

dart ×1

flutter ×1

statusbar ×1