I have a Textfield at the [Forgot_password] screen to enter the phone number and push to the [OTP_verifying] screen. But when I pop() back to the [Forgot_password] screen the delete/backspace button on IOS doesn't work.
Here is my code:
Widget _buildForm() {
String phoneNumberHintText =
_localizationService.auth__login__phone_number_label;
return Form(
key: _formKey,
child: Row(children: <Widget>[
Expanded(
child: Container(
color: Colors.transparent,
child: TextFormField(
controller: _phoneNumberController,
validator: _validatePhoneNumber,
autocorrect: false,
autofocus: true,
textInputAction: TextInputAction.done,
keyboardType: TextInputType.phone,
onChanged: _onChange,
),
),
),
]),
);}
void _submitForm() async {
_isSubmitted = true;
_setIsLoading(true);
if (_validateForm()) {
try {
// Some logic code
Navigator.pushNamed(context, '/auth/verify_phone_step',
arguments: {'phoneNumber': _phoneNumberController.text});
}
_setIsLoading(false);}
Please help. Thanks in advance!
CodePudding user response:
When you push in OTP_verifying screen from Forgot_password screen you can add this code:
FocusScope.of(context).requestFocus(FocusNode());
Navigator.pushNamed(context, '/auth/verify_phone_step',
arguments: {'phoneNumber': _phoneNumberController.text});
_phoneNumberController.clear();
CodePudding user response:
I found a temporary solution which is we can unfocus the Textfield after pop from OTP verifying screen to prevent this issue.
void _submitForm() async {
_isSubmitted = true;
_setIsLoading(true);
if (_validateForm()) {
try {
// Some logic code
Navigator.pushNamed(context, '/auth/verify_phone_step',
arguments: {'phoneNumber': _phoneNumberController.text});
} finally {
FocusScope.of(context).unfocus();
}
}
_setIsLoading(false);}