Flutter setEnabledSystemUIOverlays 隐藏顶部状态栏

Mug*_*tsu 12 dart flutter

当我使用我的 appbarwidget 设置 SystemUiOverlay.bottom 时遇到了一个问题,SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom])并注意到状态栏是隐藏的,但是一旦我拉下屏幕的上侧,它就会显示并且不会再次消失。所以我想出了为整个小部件应用程序添加一个手势检测器的想法,以便在您按下屏幕上的任何位置时始终将其隐藏。我想知道这是否是最好的解决方案,并且不会有任何性能问题或其他任何问题。有什么想法吗?

void main() => runApp(PlanetsApp());

class PlanetsApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new GestureDetector(
      onTap: () => SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]),
      child: new MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Planets App',
        color: Colors.purple,
        home: HomeScreen(),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

goo*_*s17 0

目前还没有解决这个问题的方法。当状态栏隐藏时,应用栏的高度保持不变。

请参阅github问题:https://github.com/flutter/flutter/issues/14432