gpt4 book ai didi

flutter - 在 Flutter 升级 2.2.0 之后,包含文本字段的 ShowModalBottomSheet 被键盘隐藏

转载 作者:行者123 更新时间:2023-12-04 14:07:07 24 4
gpt4 key购买 nike

在我的应用程序中,当用户单击 FAB 时,它会触发一个包含文本字段的 ModalBottomSheet。直到今天(当我更新到 flutter 2.2.0 时),下面的代码运行良好:当用户点击文本字段时,BottomSheet 向上移动,我们可以正常使用键盘。
现在,当我们点击文本框时,键盘会隐藏BottomSheet。
更新有变化吗?
这是代码:

floatingActionButton: FloatingActionButton(
backgroundColor: Colors.blue[800],
child: Icon(Icons.add),
onPressed: () {
showModalBottomSheet<void>(
isScrollControlled: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
),
),
context: context,
builder: (BuildContext context) {
return Container(
height: 250,
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(26.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
'Ajouter une liste au carnet',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.blue[800],
fontSize: 22.0,
),
),
),
SizedBox(
height: 30,
),
Column(
children: [
TextFormField(
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
focusColor: Colors.blue,
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(10.0),
),
labelText:
'Titre de la nouvelle liste'),
onChanged: (value) {
titre = value;
},
),

最佳答案

我找到了解决这个问题的方法:
我将 SingleChildScrollView 作为第一个 Child 添加到 ModalBottomSheet 并直接将“CbL”给出的填充元素添加到容器中。

 return SingleChildScrollView(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom),
child: Container(
height: 250,
感谢 CbL 的帮助:)

关于flutter - 在 Flutter 升级 2.2.0 之后,包含文本字段的 ShowModalBottomSheet 被键盘隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67633042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com