flutter 系统导航栏获得背景色而不是透明

h7appiyu  于 2023-02-25  发布在  Flutter
关注(0)|答案(1)|浏览(143)

在flutter中执行此操作时,Android上的系统导航栏将不透明:

// tell app to use fullscreen mode with rendering system ui like status bar
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);

// set color of system navigation bar to transparent
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      statusBarIconBrightness: Brightness.dark,
      systemNavigationBarColor: Colors.transparent,
      systemNavigationBarIconBrightness: Brightness.dark,
    ));

在我的例子中,NavigationBar应该在系统导航栏下可见,但却显示了背景色。有人知道问题可能是什么吗?


系统导航栏的颜色应该与上面的NavigationBar相同,但如图所示,它只是显示白色。

xnifntxz

xnifntxz1#

它起作用了,看

void main() {
  SystemChrome.setSystemUIOverlayStyle(
    const SystemUiOverlayStyle(
      systemNavigationBarColor: Color(0xFF202935),
      systemNavigationBarIconBrightness: Brightness.light,
      statusBarColor: Color(0xFF202935),
      statusBarIconBrightness: Brightness.light,
    ),
  );
  runApp(const MyApp());
}

img result

相关问题