当我按下按钮时,TextFormField将被聚焦,并且键盘将出现。如何解决此问题?
下面的代码:
data: {download_list: download_list}
答案 0 :(得分:1)
您可以像这样使用堆栈。
Stack(
alignment: Alignment.centerRight,
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: 'verify code',
prefixIcon: Icon(Icons.sms),
),
keyboardType: TextInputType.number,
),
FlatButton(
onPressed: () {},
textTheme: ButtonTextTheme.primary,
child: Text('send sms'),
),
],
)
答案 1 :(得分:1)
() {
// This will help to wait for TextField to get focus before
// we unfocus but it will happen fast so that you won't notice.
Future.delayed(Duration.zero, () {
_yourInputFocusNode.unfocus();
// Your implementation to run when tap suffixIcon in TextField
});
},
TextFormField(
focusNode: _phoneNumberFocusNode,
decoration: InputDecoration(
suffixIcon: IconButton(
icon: Icon(Icons.contacts),
onPressed: () {
Future.delayed(Duration.zero, () {
_phoneNumberTwoFocusNode.unfocus();
Navigator.pushNamed(context, 'Contacts');
});
},
),
),
),