When I press the button and the TextFormField will be focused and the keyboard will appear. How to fix this problem?
code below:
TextFormField(
controller: code,
focusNode: codeFocus,
decoration: InputDecoration(
labelText: 'verify code',
prefixIcon: Icon(Icons.sms),
suffixIcon: FlatButton(
onPressed:(){}
child: Text('send sms'),
textTheme: ButtonTextTheme.primary,
),
),
keyboardType: TextInputType.number,
),
focusNode: codeFocus,
)
An icon that appears after the editable part of the text field and after the suffix or suffixText, within the decoration's container. The size and color of the suffix icon is configured automatically using an IconTheme and therefore does not need to be explicitly given in the icon widget.
TextFormField. TextFormField wraps a TextField and integrates it with the enclosing Form . This provides additional functionality, such as validation and integration with other FormField widgets.
You can use stack like this.
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'),
),
],
)
The same question was asked few days ago by the way...
() {
// 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');
});
},
),
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With