点击文本文件时如何调回状态栏?

时间:2019-03-25 13:01:01

标签: dart flutter

我已经实现

  

SystemChrome.setEnabledSystemUIOverlays([]);

在我的主要功能中,

隐藏状态栏,但是当我点击Textfield时,我需要将其恢复。因此,用户可以使用底部栏中的后退选项。

我尝试这样做:

  

onTap:()=> SystemChrome.restoreSystemUIOverlays()

但这不起作用。

Container _getSearchBar() {
    return new Container(
      margin: const EdgeInsets.only(top: 21.0, right: 8.0, left: 8.0),
      child: new Card(
        child: new ListTile(
          leading: new Icon(Icons.search),
          title: new TextField(
            onTap: () => SystemChrome.restoreSystemUIOverlays(),
            controller: controller,
            decoration: new InputDecoration(
                hintText: 'Search', border: InputBorder.none),
          ),
          trailing: new IconButton(
            icon: new Icon(Icons.cancel),
            onPressed: () {
              controller.clear();
            },
          ),
        ),
      ),
    );
  }

1 个答案:

答案 0 :(得分:0)

根据restoreSystemUIOverlays()函数documentation,它仅返回setEnabledSystemUIOverlays()的最后一个设置,在您的情况下,这是隐藏状态栏。相反,您应该使用:

    onTap: () => SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
相关问题