底部导航栏粘在键盘顶部

chr*_*788 14 flutter flutter-layout

最近 Flutter 的更新似乎改变了 BottomNavigationBar 的行为。以前,当键盘出现时,键盘会覆盖BottomNavigationBar。但是,现在,BottomNavigationBar 出现时会粘在键盘的顶部并且始终可见。

当键盘出现时,如何将BottomNavigationBar 设置为保留在键盘下方?

  bottomNavigationBar: new BottomNavigationBar(
      type: BottomNavigationBarType.fixed,
      fixedColor: Colors.blue,
      onTap: _navigationTapped,
      currentIndex: _pageIndex,
      items: [
        new BottomNavigationBarItem(icon: new Icon(Icons.apps), title: new Text("Manage")),
        new BottomNavigationBarItem(icon: new Icon(Icons.multiline_chart), title: new Text("A")),
        new BottomNavigationBarItem(icon: new Icon(Icons.check_box), title: new Text("B")),
        new BottomNavigationBarItem(icon: new Icon(Icons.person_add), title: new Text("C")),
        new BottomNavigationBarItem(icon: new Icon(Icons.border_color), title: new Text("D")),
      ]
  ),
Run Code Online (Sandbox Code Playgroud)

Ter*_*rry 14

请确保包括父级的小部件树仅包含one脚手架。

Scaffold(
      body: const TextField(),
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        fixedColor: Colors.blue,
        onTap: (int value) {
          return value;
        },
        currentIndex: 0,
        items: [
          BottomNavigationBarItem(icon: new Icon(Icons.apps), title: new Text("Manage")),
          BottomNavigationBarItem(icon: new Icon(Icons.multiline_chart), title: new Text("A")),
          BottomNavigationBarItem(icon: new Icon(Icons.check_box), title: new Text("B")),
          BottomNavigationBarItem(icon: new Icon(Icons.person_add), title: new Text("C")),
          BottomNavigationBarItem(icon: new Icon(Icons.border_color), title: new Text("D")),
        ],
      ),
    );
Run Code Online (Sandbox Code Playgroud)

这将导致底部导航被推到键盘上方。

 return Scaffold(
      body: Scaffold(
        ....
Run Code Online (Sandbox Code Playgroud)

  • 这没有任何意义,我使用两个脚手架,一个在另一个脚手架内,并通过设置 resizeToAvoidBottomInset: false,在上脚手架内我已经解决了这个问题。 (4认同)

小智 4

resizeToAvoidBottomInset: false你的脚手架里有吗?这会导致键盘出现时底部栏上升