arc_firebase_auth_sdk 0.0.1 copy "arc_firebase_auth_sdk: ^0.0.1" to clipboard
arc_firebase_auth_sdk: ^0.0.1 copied to clipboard

A reusable Authentication SDK powered by Firebase with pre-built UI and headless mode.

Flutter Firebase Auth SDK #

A reusable Authentication SDK powered by Firebase that supports both a pre-built UI and a no-UI mode for custom implementation.

Features #

  • Dual Mode UI:
    • Default Mode: Plug-and-play AuthScreen widget.
    • Headless Mode: Exposed AuthService and streams for building custom UIs.
  • Unified Error Handling: Maps Firebase errors to custom exceptions (UserNotFoundException, InvalidCredentialsException, etc.).
  • Configurable: Enable/disable providers via AuthConfig.
  • State Management: Built-in streams for Authenticated, Unauthenticated, TokenExpired.

Installation #

  1. Add the dependency to your pubspec.yaml:
dependencies:
  flutter_firebase_auth_sdk:
    path: path/to/flutter_firebase_auth_sdk
  1. (Optional) For full Firebase support, ensure you have configured your Flutter app with Firebase:

Usage #

1. Default Mode (Pre-built UI) #

import 'package:flutter_firebase_auth_sdk/arc_firebase_auth_sdk.dart';

// ...

AuthScreen(
  config: AuthConfig(
    enableEmailPassword: true,
    enableGoogle: true,
    enableApple: true,
  ),
  authService: FirebaseAuthService(), // Or MockAuthService() for testing
  onAuthSuccess: () {
    print("User authenticated!");
  },
);

2. Headless Mode (Custom UI) #

final authService = FirebaseAuthService();

// Sign In
try {
  await authService.signInWithEmailAndPassword(
    email: 'test@example.com', 
    password: 'password'
  );
} on AuthException catch (e) {
  print(e.message);
}

// Listen to state
StreamBuilder<AuthState>(
  stream: authService.authStateChanges,
  builder: (context, snapshot) {
    if (snapshot.data?.status == AuthStatus.authenticated) {
      return HomePage();
    }
    return LoginPage();
  },
);

Error Handling #

The SDK maps Firebase errors to specific exceptions:

  • InvalidCredentialsException: Wrong email/password.
  • UserNotFoundException: User does not exist.
  • EmailAlreadyInUseException: Email already registered.
  • WeakPasswordException: Password is too weak.
  • NetworkException: Network connectivity issues.

##Screenshot

pc1 pc2 pc3
2
likes
110
points
133
downloads

Publisher

unverified uploader

Weekly Downloads

A reusable Authentication SDK powered by Firebase with pre-built UI and headless mode.

Documentation

API reference

License

MIT (license)

Dependencies

firebase_auth, firebase_core, flutter, google_sign_in

More

Packages that depend on arc_firebase_auth_sdk