当使用键盘时,模式中的安全区域将被忽略。在此示例中,您可以通过单击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) {},
),
),
),
),
),
),
),
);发布于 2020-04-09 06:55:44
我会使用Padding小部件,而不是在BotttomModalSheet中使用SafeArea,特别是因为您不需要处理屏幕顶部,首先,SafeArea只不过是一个填充小部件,请查看this。
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (context) => Padding(
padding: const EdgeInsets.all(16),
//< when safearea is removed the modal doesn't move
child: Container(
height: 500,
child: TextField(
onChanged: (v) {},
),
),
),
),如果这不是你要找的,请告诉我
https://stackoverflow.com/questions/61109899
复制相似问题