【发布时间】:2020-07-21 09:48:13
【问题描述】:
当使用键盘时,模态中的安全区域被忽略。在此示例中,您可以通过单击 TextField 来查看模态移动。如何在模态中使用 SafeArea 并避免在激活键盘时移动模态?
Scaffold(
resizeToAvoidBottomInset: false,
body: SafeArea(
child: Center(
child: FlatButton(
child: Text('open modal'),
onPressed: () => showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (context) => SafeArea( //< when safearea is removed the modal doesn't move
child: Container(
height: 500,
child: TextField(
onChanged: (v) {},
),
),
),
),
),
),
),
);
【问题讨论】: