如何解决在平台消息回调期间抛出以下 RangeError
我在尝试保留退格以删除密码中的字符时遇到以下错误,当我尝试保留电子邮件时它没有给我错误。
这是以下错误:
====================================================================================================
======== Exception caught by services library ======================================================
The following RangeError was thrown during a platform message callback:
Value not in range: 9
When the exception was thrown,this was the stack:
#0 _StringBase.substring (dart:core-patch/string_patch.dart:399:7)
#1 TextRange.textBefore (dart:ui/text.dart:2785:17)
#2 RenderEditable.delete (package:flutter/src/rendering/editable.dart:1119:37)
#3 _DeleteTextAction.invoke (package:flutter/src/widgets/default_text_editing_actions.dart:88:45)
#4 ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:518:21)
...
====================================================================================================
======== Exception caught by services library ======================================================
The following RangeError was thrown during a platform message callback:
Value not in range: 9
When the exception was thrown,this was the stack:
#0 _StringBase.substring (dart:core-patch/string_patch.dart:399:7)
#1 TextRange.textBefore (dart:ui/text.dart:2785:17)
#2 RenderEditable.delete (package:flutter/src/rendering/editable.dart:1119:37)
#3 _DeleteTextAction.invoke (package:flutter/src/widgets/default_text_editing_actions.dart:88:45)
#4 ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:518:21)
...
====================================================================================================
这是我拥有的以下TextFormField
:
DefaultTextFormField(
controller: passwordController,type: TextInputType.visiblePassword,suffix: controller.suffix,onSubmit: (value) {
if (_formKey.currentState.validate()) {
controller.signInWithEmailAndPassword();
}
},isPassword: controller.isPassword,suffixPressed: () {
controller.changePasswordVisibility();
},validate: (String value) {
if (value.isEmpty) {
return 'password is too short';
}
},label: 'Password',prefix: Icons.lock_outline,),
这是我用于通过电子邮件登录的以下方法:
void signInWithEmailAndPassword() async {
try {
await _auth.signInWithEmailAndPassword(email: email,password: password);
Get.offAll(HomeView());
} catch (e) {
print(e.message);
Get.snackbar(
'Error login account',e.message,colorText: Colors.black,snackPosition: SnackPosition.BOTTOM,);
}
}
因为我正在使用 GetX
状态管理..
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。