FB.login() called before FB.init() - Flutter

371 views Asked by At

Trying to:
Authorize via facebook login on web

Problem:
I get the error: FB.login() called before FB.init().

What I'm doing:
I'm using package flutter_facebook_auth: ^5.0.6 for my flutter project. It works fine with Android and iOS, but fails on web.

The main.dart-file initialises facebook before I call the login, so I'm not sure what I need to do. This is my main-file:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  if(kIsWeb){
    await FacebookAuth.i.webAndDesktopInitialize(
        appId: "provided in the real code",
        cookie: true,
        xfbml: true,
        version: "v14.0"
    );
  }
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  runApp(const ProviderScope(child: App()));
}
.
.
.
0

There are 0 answers