Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Login With Flutter

Future<FirebaseUser> login({List<String> userData, var loginCallback, var cancelledCallback,
        var errorCallback}) async {
    var facebookLogin = FacebookLogin();
    var facebookLoginResult = await facebookLogin.logInWithReadPermissions(['email']);
    switch (facebookLoginResult.status) {
      case FacebookLoginStatus.error:
        print("Error");
        break;
      case FacebookLoginStatus.cancelledByUser:
        print("CancelledByUser");
        break;
      case FacebookLoginStatus.loggedIn:
        print("LoggedIn");
        break;
    }
  }

Using flutter_facebook_login plugin and it always throws this error.Couldn't figure out where am i going wrong. Here is the logcat for the error.

MissingPluginException(No implementation found for method loginWithReadPermissions on channel com.roughike/flutter_facebook_login)
E/flutter ( 6174): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:278:7)
E/flutter ( 6174): <asynchronous suspension>
E/flutter ( 6174): #1      FacebookLogin.logInWithReadPermissions (package:flutter_facebook_login/flutter_facebook_login.dart:101:23)
E/flutter ( 6174): <asynchronous suspension>
E/flutter ( 6174): #2      FacebookAuth.login (package:shout_out/util/social_login.dart:26:25)
like image 640
ujjwal mainali Avatar asked Aug 18 '18 08:08

ujjwal mainali


People also ask

How do I enable Facebook login on flutter?

Ok once you are at the firebase project you can go to Authentication and then select sign-in methods. 4. Select the Facebook option, it will ask for your App ID and App secret the one you got from Facebook for developers.


3 Answers

MissingPluginException usually occurs when you add a plugin and doesnt re-run your app from the start.

Try to kill your application and again run it. The problem will go away.

Edit

Facebook sdk for flutter requires to have some additions in your manifest file (For android), the changes are documented in the plugin documentation.

like image 146
Jaswant Singh Avatar answered Sep 20 '22 18:09

Jaswant Singh


AndroidX support #

if you don't know what android X is, Simply use this one (1.2.0) and the Error will be Solved

if you want to avoid AndroidX, use version 1.2.0.

flutter_facebook_login: ^1.2.0

if you want to use the latest version please refer about Android X

for AndroidX Flutter projects, use versions 2.0.0 and up.

flutter_facebook_login: ^2.0.0

like image 28
Arun R. Prajapati Avatar answered Sep 17 '22 18:09

Arun R. Prajapati


For android studio go to the file > invalidate caches / restart.....

it is working for me so, I hope it will work for you...

enter image description here

like image 20
Mohit Modh Avatar answered Sep 21 '22 18:09

Mohit Modh