Skip to content

Latest commit

 

History

History
89 lines (63 loc) · 2.43 KB

File metadata and controls

89 lines (63 loc) · 2.43 KB

Firebase UI for authentication

Firebase UI for authentication provides a simple and easy way to implement authentication in your Flutter app. The library provides fully featured UI screens to drop into new or existing applications, along with lower level abstractions for developers looking for tighter control.

Installation

Activate FlutterFire CLI

dart pub global activate flutterfire_cli

Install dependencies

flutter pub add firebase_core
flutter pub add firebase_auth
# required for email link sign in and email verification
flutter pub add firebase_dynamic_links
flutter pub add firebase_ui_auth

Configuration

Configure firebase using cli:

flutterfire configure

Initialize firebase app:

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
}

macOS entitlements

If you're building for macOS, make sure to add necessary entitlements. Learn more from the official Flutter documentation.

Writing widget unit tests

If you're writing widget unit tests, you'll need to add the following to your setUpAll method:

setUpAll(() {
  setFirebaseUiIsTestMode(true);
});

Also, you will likely want to mock the FirebaseAuth instance:

class MockFirebaseAuth extends Mock implements FirebaseAuth {
  /// mock necessary methods
}

An instance of MockFirebaseAuth can then be passed to Firebase UI widgets:

SignInScreen(
  auth: MockFirebaseAuth(),
  /// ... other props
)

Next steps

To understand what Firebase UI for authentication offers, the following documentation pages walk you through the various topics on how to use the package within your Flutter app.