firebase_auth_helper 2.2.4 copy "firebase_auth_helper: ^2.2.4" to clipboard
firebase_auth_helper: ^2.2.4 copied to clipboard

Firebase Auth Helper. Provides a AuthProvider interface and FirebaseAuth implementation of it.

An AuthProvider interface with FirebaseAuth implementation

Usage #


final AuthProvider authProvider = FirebaseAuthProvider.fromInstance();
authProvider.signOut();
final signInResult = authProvider.emailPasswordSignIn(
    LoginCredentials("some@email.com", "secretPassword"));
final AuthUser? currentUser = authProvider.currentAuthUser;
if (currentUser != null) {
print("""
    Currently logged in as: ${currentUser.displayName},
    ${currentUser.email},
    ${currentUser.id}""");
} else {
print("Not logged in");
}

authProvider.authStateChanged.listen((authUser) {
print("Auth user changed");
print("Is logged in: ${authUser != null}");
if (authUser != null) {
print(
"Currently logged in as: ${authUser.displayName}, ${authUser.email}, ${authUser.id}");
}
});

Use the AuthStateWrapper to handle listening to the current auth state and display the correct page accordingly.


final AuthStateWrapper authStateWrapper = AuthStateWrapper(
    authProvider: authProvider,
    signedIn: (context) => HomePage(),
    notSignedIn: (context) => LoginPage(),
    loading: (context) => const CircularProgressIndicator(),
    error: (context, error) => Text("Error occurred: $error"));
2
likes
120
pub points
56%
popularity

Publisher

unverified uploader

Firebase Auth Helper. Provides a AuthProvider interface and FirebaseAuth implementation of it.

Documentation

API reference

License

MIT (LICENSE)

Dependencies

firebase_auth, firebase_core, flutter

More

Packages that depend on firebase_auth_helper