当用户单击屏幕或打开键盘时,如何隐藏状态栏和导航栏? [英] How to hide status bar and navigation bar in flutter when user clicks on screen or open keyboard?

查看:145
本文介绍了当用户单击屏幕或打开键盘时,如何隐藏状态栏和导航栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个全屏的Flutter应用程序。
,但问题是当用户触摸屏幕时,出现顶部状态栏,或者当用户触摸文本字段时,出现底部状态栏和顶部状态栏。

I have a flutter app that is fullscreen . but the problem is when user touches screen the Top Status Bar appears , or When user touches a textfield , the Bottom Status Bar and Top Status Bar appears .

如何预防此问题。

这是我制作Flutter应用程序的全屏代码:

Here is My Code For Make Flutter App fullscreen :

await SystemChrome.setPreferredOrientations(
      [DeviceOrientation.landscapeRight]);
await SystemChrome.setEnabledSystemUIOverlays([]);


推荐答案

输出:

我不确定您在哪里使用该通话。这是最小的代码重现。

I'm not sure where are you using that call. Here is minimum code reproduction.

void main() => runApp(MaterialApp(home: HomePage()));

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    super.initState();
    SystemChrome.setEnabledSystemUIOverlays([]);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Full screen")),
      body: SizedBox.expand(child: FlutterLogo()),
    );
  }
}

这篇关于当用户单击屏幕或打开键盘时,如何隐藏状态栏和导航栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆