firebase_ui_oauth_facebook 1.2.9 copy "firebase_ui_oauth_facebook: ^1.2.9" to clipboard
firebase_ui_oauth_facebook: ^1.2.9 copied to clipboard

Firebase UI widgets for authentication & OAuth.

Firebase UI OAuth Facebook #

pub package

Facebook Sign In for Firebase UI Auth

Installation #

Add dependencies

flutter pub add firebase_ui_auth
flutter pub add firebase_ui_oauth_facebook

flutter pub global activate flutterfire_cli
flutterfire configure

Enable Facebook provider on firebase console.

Usage #

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
import 'package:firebase_ui_oauth_facebook/firebase_ui_oauth_facebook.dart';

void main() {
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);

    FirebaseUIAuth.configureProviders([
        FacebookProvider(clientId: 'clientId'),
    ]);

    runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key}) ;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SignInScreen(
        actions: [
          AuthStateChangeAction<SignedIn>((context, state) {
            // redirect to other screen
          })
        ],
      ),
    );
  }
}

Alternatively you could use the OAuthProviderButton

class MyScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AuthStateListener<OAuthController>(
      listener: (oldState, newState, controller) {
        if (newState is SignedIn) {
          // navigate to other screen.
        }
      },
      child: OAuthProviderButton(
        provider: FacebookProvider(clientId: 'clientId'),
      ),
    );
  }
}

Also there is a standalone version of the FacebookSignInButton

class MyScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FacebookSignInButton(
      clientId: 'clientId',
      loadingIndicator: CircularProgressIndicator(),
      onSignedIn: (UserCredential credential) {
        // perform navigation.
      }
    );
  }
}

For issues, please create a new issue on the repository.

For feature requests, & questions, please participate on the discussion thread.

To contribute a change to this plugin, please review our contribution guide and open a pull request.

Please contribute to the discussion with feedback.