未经手的例外:null检查操作员在null值profile_view.dart上使用:938:61)
未经手的例外:
null检查运算符上使用的null值 e/flutter(31702):#0 _profileviewstate.login (软件包:.../profile/profile_view.dart:938:61)
profile_view.dart:938:61
login(PhoneAuthCredential credential, RunMutation mutationCall) async {
final UserCredential cr =
await FirebaseAuth.instance.signInWithCredential(credential);
final String firebaseToken = await cr.user!.getIdToken();
final args = LoginArguments(firebaseToken: firebaseToken).toJson();
final netResult = await mutationCall(args).networkResult;
***final loginRes = Login$Mutation.fromJson(netResult!.data!);***
final jwt = loginRes.login.jwtToken;
Hive.box('user').put('jwt', jwt);
setState(() {
verifyState = StepState.complete;
_currentStep = 2;
});
}
如何解决?
Unhandled Exception:
Null check operator used on a null value
E/flutter (31702): #0 _ProfileViewState.login
(package:.../profile/profile_view.dart:938:61)
profile_view.dart:938:61
login(PhoneAuthCredential credential, RunMutation mutationCall) async {
final UserCredential cr =
await FirebaseAuth.instance.signInWithCredential(credential);
final String firebaseToken = await cr.user!.getIdToken();
final args = LoginArguments(firebaseToken: firebaseToken).toJson();
final netResult = await mutationCall(args).networkResult;
***final loginRes = Login$Mutation.fromJson(netResult!.data!);***
final jwt = loginRes.login.jwtToken;
Hive.box('user').put('jwt', jwt);
setState(() {
verifyState = StepState.complete;
_currentStep = 2;
});
}
how can I solve it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将鼓励在不检查NULL的情况下直接使用
!
。在这个片段中,很少有我们的零用方体。在使用
!
之前,请检查该变量。就像您的情况一样,摘要可能
I will encourage not to use
!
directly without checking null. In this snippet there are few cases we can get null.Before using
!
do a null check on the variable. likeIn your case, snippet can be like