0

i have been trying to login with facebook authentication with is this plugin

here the facebook plugin

but i keep getting this error after given me a token listeners about the user

 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): 

here is my code

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; } } } 

then i call it in my 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, ), ), 

i am having a hard time to locate the error is coming from..

thanks

2
  • The problem is here print('Error ${error.code}');. Why do you think this execption has a field as code? Doesn't seem like you have any custom exception in your code. Probabaly print('Error ${error.messgae}'); is what you are looking for? Commented May 11, 2021 at 18:25
  • Ignoring header X-Firebase-Locale because its value was null. i am getting this in the console. and is passing null to firestore Commented May 11, 2021 at 18:39

1 Answer 1

1

The error is in login.dart , 157:49

Check those lanes

Probably ${e.code} or ${err.code} doesn't have "code". Try put a breakpoint there and see what has e and err

Put it exactly here: await Flushbar(

Otherwise won't stop

Sign up to request clarification or add additional context in comments.

6 Comments

i am getting null in the facebook authentication please why?
Check your credentials if are ok, and also if you are logging correctly
the credentials is okay, and i am logging correctly but i keep given me error
Ignoring header X-Firebase-Locale because its value was null. i am getting this in the console
That comment is related about connection to Firebase, not to Facebook. Did you check the credentials about firebase are ok? There are a few pots in stack overflow with that error, for example... stackoverflow.com/a/66993601/5477131 Also check how are you connecting to firebase.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.