Flutter 颤振:如何用键盘向上移动模型底板?
这是屏幕截图。单击FloatingAction按钮时,我显示的是modekBottomSheet。modelBottomSheet有4个文本字段和1个RaisedButton。我希望文本字段和升高的按钮与键盘一起上升。升起的按钮底部应位于键盘顶部Flutter 颤振:如何用键盘向上移动模型底板?,flutter,Flutter,这是屏幕截图。单击FloatingAction按钮时,我显示的是modekBottomSheet。modelBottomSheet有4个文本字段和1个RaisedButton。我希望文本字段和升高的按钮与键盘一起上升。升起的按钮底部应位于键盘顶部 floatingActionButton: FloatingActionButton( onPressed: () { showModalBottomSheet( isScrollControlled: true,
floatingActionButton: FloatingActionButton(
onPressed: () {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (context) {
return _showModelBottomSheetContent(context);
},
);
},
backgroundColor: Colors.blue,
child: Icon(
Icons.add,
size: 30,
),
),
Container _showModelBottomSheetContent(BuildContext context) {
return Container(
color: Color(0xFF737373),
height: 440,
child: Container(
padding: EdgeInsets.only(top: 20, left: 12, right: 12, bottom: 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
"Add Customer",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
),
TextField(
style: TextStyle(fontSize: 18),
decoration: InputDecoration(
hintText: "Customer Name",
fillColor: Colors.white54,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(8.0),
borderSide: new BorderSide(),
),
),
),
TextField(
keyboardType: TextInputType.number,
style: TextStyle(fontSize: 18),
decoration: InputDecoration(
hintText: "Mobile No",
fillColor: Colors.white54,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(8.0),
borderSide: new BorderSide(),
),
),
),
TextField(
keyboardType: TextInputType.number,
style: TextStyle(fontSize: 18),
decoration: InputDecoration(
hintText: "Altername mobile no.",
fillColor: Colors.white54,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(8.0),
borderSide: new BorderSide(),
),
),
),
TextField(
style: TextStyle(fontSize: 18),
decoration: InputDecoration(
hintText: "Address",
fillColor: Colors.white54,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(8.0),
borderSide: new BorderSide(),
),
),
),
RaisedButton(
padding: EdgeInsets.only(top: 10, bottom: 10),
color: Colors.blue,
child: Text(
'ADD',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w700),
),
onPressed: handleAddCustomer,
),
SizedBox(
height: 20,
)
],
),
decoration: BoxDecoration(
color: Theme.of(context).canvasColor,
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(12),
topRight: const Radius.circular(12),
),
),
),
);
floatingActionButton:floatingActionButton(
已按下:(){
showModalBottomSheet(
是的,
上下文:上下文,
生成器:(上下文){
return\u showModelBottomSheetContent(上下文);
},
);
},
背景颜色:Colors.blue,
子:图标(
Icons.add,
尺码:30,
),
),
容器\u showModelBottomSheetContent(构建上下文上下文){
返回容器(
颜色:颜色(0xFF737373),
身高:440,
子:容器(
填充:仅限边集(顶部:20,左侧:12,右侧:12,底部:20),
子:列(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
crossAxisAlignment:crossAxisAlignment.stretch,
儿童:[
正文(
“添加客户”,
textAlign:textAlign.center,
样式:TextStyle(fontSize:20,fontWeight:fontWeight.w600),
),
文本字段(
样式:TextStyle(字体大小:18),
装饰:输入装饰(
hintText:“客户名称”,
fillColor:Colors.white54,
边框:新大纲输入边框(
边界半径:新边界半径。圆形(8.0),
borderSide:新的borderSide(),
),
),
),
文本字段(
键盘类型:TextInputType.number,
样式:TextStyle(字体大小:18),
装饰:输入装饰(
hintText:“手机号码”,
fillColor:Colors.white54,
边框:新大纲输入边框(
边界半径:新边界半径。圆形(8.0),
borderSide:新的borderSide(),
),
),
),
文本字段(
键盘类型:TextInputType.number,
样式:TextStyle(字体大小:18),
装饰:输入装饰(
hintText:“Altername手机号码”,
fillColor:Colors.white54,
边框:新大纲输入边框(
边界半径:新边界半径。圆形(8.0),
borderSide:新的borderSide(),
),
),
),
文本字段(
样式:TextStyle(字体大小:18),
装饰:输入装饰(
hintText:“地址”,
fillColor:Colors.white54,
边框:新大纲输入边框(
边界半径:新边界半径。圆形(8.0),
borderSide:新的borderSide(),
),
),
),
升起的按钮(
填充:仅限边缘设置(顶部:10,底部:10),
颜色:颜色,蓝色,
子:文本(
“添加”,
样式:TextStyle(
颜色:颜色,白色,
尺码:18,
fontWeight:fontWeight.w700),
),
按下按钮:手持式客户,
),
大小盒子(
身高:20,
)
],
),
装饰:盒子装饰(
颜色:主题。背景。画布颜色,
borderRadius:仅限borderRadius(
左上角:常数半径。圆形(12),
右上角:常数半径。圆形(12),
),
),
),
);
}我尝试将底部填充设置为MediaQuery.of(context).viewInsets.bottom,但不起作用尝试读取此对话中的所有消息尝试了所有操作,但均无效