我正在使用Flutter构建待办事项应用程序。当我按下floatingActionButton时,将显示ModalBottomSheet,当我按下“重复”按钮时,键盘将关闭,并使popupMenu浮动。如何防止键盘消失?
当我按“重复”时
这是我的代码
DateTime selectedDate = DateTime.now();
List <PopupMenuItem<String>> _pop = ['Daily', 'Weekly', 'Monthly'].map((String value){
return PopupMenuItem <String>(
value: value,
child: Text(value),
);
}).toList();
// When press on floatingActionButton
showAddBottomSheet(BuildContext parentContext, HomeState homeState){
showModalBottomSheet(
context: parentContext,
isScrollControlled: true,
builder: (BuildContext context){
return Container(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottm),
child: StatefulBuilder(
builder: (context, setState){
return Container(
height: 200,
child: Column(
children: [
Container(
padding: EdgeInsets.only(bottom: 10),
child: TextField(
autofocus: true,
controller: addController,
),
),
PopupMenuButton <String>(
child:Row(children: [Icon(Icons.repeat), Text('Repeat')], mainAxisAlignment:
MainAxisAlignment.center, mainAxisSize: MainAxisSize.min,)
onSelected: (value){
setState((){
taskRepetition = value;
});
},
itemBuilder: (BuildContext context) {
return _pop;
}
),
Container(
padding: EdgeInsets.only(top: 8),
child: RaisedButton(
child: Text('Select Date'),
onPressed: () async {
},
color: Colors.green,
),
),
RaisedButton(
child: Text('Add'),
onPressed: (){
},
color: Colors.blueAccent,
),
],
),
);
}
),
);
}
);
}