roughike / flutter_facebook_login

A Flutter plugin for allowing users to authenticate with native Android & iOS Facebook login SDKs.
BSD 2-Clause "Simplified" License
403 stars 331 forks source link

Firebaseauth with Facebook login #100

Open samycodes opened 5 years ago

samycodes commented 5 years ago

Hey guys, I am trying to login Firebase with facebook.

I am using firebaseauth:0.7.0 and flutter_facebook_login:

Here is my function for facebook login:

  startFacebookLogin() async {
    var facebookLogin = FacebookLogin();
    var result = await facebookLogin
        .logInWithReadPermissions(['email', 'public_profile']);
    FacebookAccessToken myToken = result.accessToken;
    AuthCredential credential =
        FacebookAuthProvider.getCredential(accessToken: myToken.token);
    FirebaseUser firebaseUser =
        await FirebaseAuth.instance.signInWithCredential(credential);
    createProfile(user);
  }

Here I got this error:

E/flutter (19097): [ERROR:flutter/shell/common/shell.cc(186)] Dart Error: Unhandled exception:
E/flutter (19097): NoSuchMethodError: The getter 'token' was called on null.
E/flutter (19097): Receiver: null
E/flutter (19097): Tried calling: token
E/flutter (19097): #0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
E/flutter (19097): #1      _SignUpFirst.startFacebookLogin (package:tripmate/pages/signup_first.dart:40:65)
E/flutter (19097): <asynchronous suspension>
E/flutter (19097): #2      _SignUpFirst.build.<anonymous closure> (package:tripmate/pages/signup_first.dart:254:27)
E/flutter (19097): #3      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (19097): #4      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (19097): #5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (19097): #6      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (19097): #7      TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
E/flutter (19097): #8      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter (19097): #9      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (19097): #10     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (19097): #11     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
E/flutter (19097): #12     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
E/flutter (19097): #13     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
E/flutter (19097): #14     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (19097): #15     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter (19097): #16     _invoke1 (dart:ui/hooks.dart:173:13)
E/flutter (19097): #17     _dispatchPointerDataPacket (dart:ui/hooks.dart:127:5)
I/System.out(19097): (HTTPLog)-Static: isSBSettingEnabled false
I/System.out(19097): (HTTPLog)-Static: isSBSettingEnabled false

Can anyone help me with this?

bilalbaz1 commented 4 years ago

hello, did you find the solution to this error?