flutter - 用电话号码颤动登录
问题描述
我有一个问题,我无法解决。
在我点击验证按钮(第二张图片)后,它会返回第一张照片,仅此而已,就像 navigator.pop() 函数一样。
我有提供使用电话号码登录的功能,在这里:
Future<void> signInWithTelephoneNumber({String phoneNumber}) async {
emit(state.copyWith(phoneNumber: phoneNumber,isInProgress: true, errorMessage: ""));
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: "+9$phoneNumber",
timeout: const Duration(seconds: 30),
verificationCompleted: (PhoneAuthCredential credential) async {
await FirebaseAuth.instance.signInWithCredential(credential);
print("Successsssssssssssssssssss");
},
verificationFailed: (FirebaseAuthException e) {
if (e.code == 'invalid-phone-number') {
print('The provided phone number is not valid.');
emit(state.copyWith(errorMessage: "The provided phone number is not valid."));
}
},
codeSent: (String verificationId, int resendToken) async {
String smsCode = '123456';
PhoneAuthCredential credential = PhoneAuthProvider.credential(
verificationId: verificationId, smsCode: smsCode);
await FirebaseAuth.instance.signInWithCredential(credential);
},
codeAutoRetrievalTimeout: (String verificationId) {},
);
emit(state.copyWith(phoneNumber: "",isInProgress: false, errorMessage: ""));
}
当我单击登录按钮时,它会进入验证页面(chapcta 页面),在我验证图像后,它会出现此错误:
Notifying id token listeners about user ( RID5Hq65CCcj1hXgyvVosA6QKbo1 ).
D/FirebaseAuth( 2708): Notifying auth state listeners about user ( RID5Hq65CCcj1hXgyvVosA6QKbo1 ).
E/flutter ( 2708): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
我该怎么办 ?我怎么解决这个问题 ?我使用此链接作为来源:https ://firebase.flutter.dev/docs/auth/phone/
解决方案
我使用了 showDialog 并为短信代码提供输入。谢谢
推荐阅读
- dictionary - RavenDB 查询与特定日期范围的父项和最后一个子项的投影
- node.js - 单元测试 express-validator 中间件
- c - 如何放大一个点(背后的数学)
- node.js - 在 windows 中的电子项目上安装 node-webcrypto-ossl 会引发错误
- c++ - 以 nullptr 作为参数的函数重载解析
- javascript - 节点快速循环会话数据
- vue.js - [Framework7 Vuejs]使用v-for将异步数据绑定到模板
- selenium - 没有将测试用例导出为的 selenium IDE
- c++ - 为什么选择值 {1, 1, 0, -1, -1, -1, 0, 1} 和 {0, 1, 1, 1, 0, -1, -1, -1} 用于 dx[dir ] 和 dy[目录]?
- python-3.x - cv2.HOGDescriptor 的计算方法总是返回一个空元组