我一直在尝试使用此插件进行 facebook 身份验证登录
但是在给我一个关于用户的令牌侦听器后,我不断收到此错误
D/FirebaseAuth(16644): Notifying id token listeners about user ( 7fJCaA1cplgINtOJuvi2AYxd4dG3 ).
E/flutter (16644): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: NoSuchMethodError: Class 'NoSuchMethodError' has no instance getter 'code'.
E/flutter (16644): Receiver: Instance of 'NoSuchMethodError'
E/flutter (16644): Tried calling: code
E/flutter (16644): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
E/flutter (16644): #1 LoginState.build.<anonymous closure>.<anonymous closure> (package:FaithMeetsLove/view/login.dart:157:49)
E/flutter (16644): <asynchronous suspension>
E/flutter (16644):
这是我的代码
class authenticationApi{
Future<bool> signInFacebook() async {
try {
final result = await facebookLogin.logIn(['email', 'public_profile']);
switch (result.status) {
case FacebookLoginStatus.loggedIn:
final token = result.accessToken.token;
final credential =
FacebookAuthProvider.credential(token);
final user = (await auth.signInWithCredential(credential)).user;
return true;
break;
case FacebookLoginStatus.cancelledByUser:
break;
case FacebookLoginStatus.error:
print(".....Here is Status Error...........${result.errorMessage}");
break;
}
return true;
} catch (error) {
print('Error ${error.code}');
return false;
}
}
}
然后我在我的 login.dart
中调用它 GestureDetector(
onTap: ()async {
final progress = ProgressHUD.of(context);
progress?.showWithText('Loging in...');
try {
final facebook = await AuthenticationApi().signInFacebook();
if(facebook){
await checkDataFromDB();
progress?.dismiss();
}else{
progress?.dismiss();
await Flushbar(
title: 'Ops!',
message: 'Sign in not completed, Try again!!!',
duration: Duration(seconds: 3),
).show(context);
}
} on PlatformException catch (err){
progress?.dismiss();
await Flushbar(
title: 'Ops!',
message: 'error ${err.code}',
duration: Duration(seconds: 3),
).show(context);
} catch (e) {
progress?.dismiss();
await Flushbar(
title: 'Ops!',
message: 'error ${e.code}',
duration: Duration(seconds: 3),
).show(context);
}
},
child: LoginBtn(
icon: FontAwesomeIcons.facebook,
),
),
我很难找到错误来自..
谢谢
答案 0 :(得分:0)
错误在 login.dart , 157:49
检查那些车道
可能 ${e.code}
或 ${err.code}
没有“代码”。尝试在那里放置一个断点,看看有 e
和 err
准确地放在这里:await Flushbar(
否则不会停止