我有以下代码:
return Scaffold(
appBar: AppBar(
title: Text('Sample Code'),
),
body: ListView(
padding: const EdgeInsets.all(20.0),
children: <Widget>[
TextField(
decoration: InputDecoration(labelText: "Text"),
),
TextField(
decoration: InputDecoration(labelText: "Text"),
),
TextField(
decoration: InputDecoration(labelText: "Text"),
),
],
),
bottomNavigationBar: BottomAppBar(
child: Container(
height: 50.0,
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
);
每当键盘出现并输入文本时TextField
the FloatingActionButton
向上移动到键盘顶部,如下所示:
我想要的是按钮保留在底部导航栏中,并且在键盘显示时不移动。我添加了resizeToAvoidBottomPadding: false,
to the Scaffold
,这会阻止按钮移动,但也会阻止我ListView
当键盘出现时,从移动到保持可见。