gpt4 book ai didi

dart - 尝试使用电子邮件和密码创建帐户时,Flutter应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 03:05:43 24 4
gpt4 key购买 nike

这是我创建帐户的代码,但是当已经注册了电子邮件ID时,应用崩溃了,而我的try catch方法无法捕获它。
如何解决这个问题?

void careteAccount() async {
if (in_email.text.trim().length > 0 && in_password.text.trim().length > 0) {
try {
// FirebaseAuth.instance.verifyPhoneNumber(phoneNumber: "+919656936681", codeAutoRetrievalTimeout: (String verificationId) {}, codeSent: (String verificationId, int forceResendingToken) {}, timeout: null, verificationCompleted: (FirebaseUser firebaseUser) {}, verificationFailed: (AuthException error) {});

FirebaseUser user = await FirebaseAuth.instance
.createUserWithEmailAndPassword(
email: in_email.value.text.trim(), password: in_password.value.text.trim())
.catchError((e){
print(e.toString());
Fluttertoast.showToast(
msg: e.toString(),
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.TOP,
timeInSecForIos: 1,
backgroundColor: Colors.black54,
textColor: Colors.white);
})
.then((u){
if(u!=null?u.email!=null?true:false:false){
print("account created "+u.email);
}else{
print("account creatin failed");
}
});
print("create accound in ${user.email}");
} catch (e) {
print(e.toString());
Fluttertoast.showToast(
msg: e.toString(),
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.TOP,
timeInSecForIos: 1,
backgroundColor: Colors.black54,
textColor: Colors.white);
print('Error $e');
}
} else {
print("login called and countroler is null");
}}

错误消息“给定的密码无效。[密码至少应包含6个字符]”

firebase flutter auth error

我需要以编程方式找出错误,而不是上面的图像

D/ ( 8896): HostConnection::get() New Host Connection established 0xb40f0c90, tid 8923 D/EGL_emulation( 8896): eglMakeCurrent: 0xb42bc4c0: ver 2 0 W/BiChannelGoogleApi( 8896): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@3b1fc27b



成功创建帐户时出错
I/flutter ( 9012): account created milla@gmail.com
Unhandled exception:
NoSuchMethodError: The getter 'className' was called on null.
Receiver: null
Tried calling: className
#0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1 serializeProcedure (package:front_end/src/fasta/kernel/utils.dart:99:29)
#2 FrontendCompiler.compileExpression (package:vm/frontend_server.dart:482:16)
<asynchronous suspension>
#3 _FlutterFrontendCompiler.compileExpression (package:frontend_server/server.dart:62:22)
#4 listenAndCompile.<anonymous closure> (package:vm/frontend_server.dart:797:20)
<asynchronous suspension>
#5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#8 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#9 _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#10 _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
#11 _LineSplitterSink._addLines (dart:convert/line_splitter.dart:154:13)
#12 _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:129:5)
#13 StringConversionSinkMixin.add (dart:convert/string_conversion.dart:189:5)
#14 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#15 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#16 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#17 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#18 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#19 _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#20 _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
#21 _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:273:7)
#22 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:348:20)
#23 _Utf8ConversionSink.add (dart:convert/string_conversion.dart:341:5)
#24 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:86:18)
#25 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#26 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
#27 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#28 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)

最佳答案

在Firebase中,密码必须至少为6个字符。

关于dart - 尝试使用电子邮件和密码创建帐户时,Flutter应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53898572/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com