首页 文章

Flutter setEnabledSystemUIOverlays隐藏顶部状态栏

提问于
浏览
1

当我使用 SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]) 在appbarwidget上设置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(),
      ),
    );
  }
}

2 回答

  • 0

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

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

  • 0

    将您的代码更改为此 .

    SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values));
    

相关问题