我在 [Forgot_password] 螢屏上有一個文本欄位,用于輸入電話號碼并推送到 [OTP_verifying] 螢屏。但是當我 pop() 回到 [Forgot_password] 螢屏時,IOS 上的洗掉/退格按鈕不起作用。
這是我的代碼:
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);}
請幫忙。提前致謝!
uj5u.com熱心網友回復:
當您從 Forgot_password 螢屏推送 OTP_verifying 螢屏時,您可以添加以下代碼:
FocusScope.of(context).requestFocus(FocusNode());
Navigator.pushNamed(context, '/auth/verify_phone_step',
arguments: {'phoneNumber': _phoneNumberController.text});
_phoneNumberController.clear();
uj5u.com熱心網友回復:
我找到了一個臨時解決方案,即我們可以在從 OTP 驗證螢屏彈出后取消聚焦文本欄位以防止出現此問題。
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);}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/354730.html
上一篇:來自功能組件的條件渲染
