### Install addlicense Tool Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md Install the addlicense tool globally using go install. This tool is used to add license headers to project files. ```bash go install github.com/google/addlicense@latest ``` -------------------------------- ### Install Application Target Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Installs the main application executable to the runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Directory and Default Build Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Sets the installation directory to be next to the executable and makes the 'install' step the default build action for Visual Studio. ```cmake set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Installation Bundle Configuration Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Sets up the installation prefix to create a relocatable bundle in the build directory and ensures a clean bundle directory on each build. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Installing Application Executable and Data Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Installs the application executable to the root of the bundle, and ICU data to the data directory. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Installs any bundled libraries associated with plugins to the library directory. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Flutter Library Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Installs the main Flutter library file to the library directory within the application bundle. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Flutter App Authentication Example Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/README.md This example demonstrates how to set up a basic authentication flow using SignInScreen and ProfileScreen, including state change actions for user creation and sign-in, and sign-out actions. ```dart import 'package:flutter/material.dart'; import 'package:firebase_auth/firebase_auth.dart' hide EmailAuthProvider; import 'package:firebase_ui_auth/firebase_ui_auth.dart'; class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { final providers = [EmailAuthProvider()]; void onSignedIn() { Navigator.pushReplacementNamed(context, '/profile'); } return MaterialApp( initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile', routes: { '/sign-in': (context) { return SignInScreen( providers: providers, actions: [ AuthStateChangeAction((context, state) { // Put any new user logic here onSignedIn(); }), AuthStateChangeAction((context, state) { onSignedIn(); }), ], ); }, '/profile': (context) { return ProfileScreen( providers: providers, actions: [ SignedOutAction((context) { Navigator.pushReplacementNamed(context, '/sign-in'); }), ], ); }, }, ); } } ``` -------------------------------- ### Install Native Assets Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Installs native assets provided by build.dart from all packages into the library directory. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Start Firebase Emulator Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md Start the Firebase Emulator suite, which is required for running end-to-end tests. Ensure the emulator is running before executing E2E tests. ```bash melos emulator:start ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Initializes CMake version and project name. Sets the executable name and application identifier. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "tests") set(APPLICATION_ID "io.flutter.plugins.firebase.tests") ``` -------------------------------- ### Installing Flutter Library and Bundled Libraries Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Installs the main Flutter library and any bundled plugin libraries into the bundle's lib directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install firebase_ui_auth and dependencies Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Installs the firebase_ui_auth package and its required dependencies using dart pub and flutter pub. ```sh dart pub global activate flutterfire_cli flutter pub add firebase_core firebase_auth firebase_ui_auth flutterfire configure ``` -------------------------------- ### Install AOT Library Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compilation library to the data directory, but only for Profile and Release build configurations. ```cmake # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Installing Flutter Assets Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Removes stale assets and installs the current Flutter assets directory into the bundle's data directory. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Installs the ICU data file to the data directory within the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Removes existing Flutter assets and then copies the new assets from the build directory to the data directory, ensuring assets are up-to-date. ```cmake # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Default SignInScreen with MaterialApp Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/theming.md This example shows a basic `SignInScreen` with an `EmailAuthProvider` wrapped in a `MaterialApp`. It will render with default Material styling. ```dart class FirebaseAuthUIExample extends StatelessWidget { @override Widget build(BuildContext context) { return const MaterialApp( home: SignInScreen( providers: [ EmailAuthProvider(), ], ), ); } } ``` -------------------------------- ### Add Dependencies Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-storage/getting-started.md Install the required packages for Firebase UI Storage using Flutter. ```sh flutter pub add firebase_core firebase_storage firebase_ui_storage ``` -------------------------------- ### Add Facebook Provider Dependency Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/oauth.md Install the `firebase_ui_oauth_facebook` package to enable Facebook authentication. ```sh flutter pub add firebase_ui_oauth_facebook ``` -------------------------------- ### Add Twitter Provider Dependency Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/oauth.md Install the `firebase_ui_oauth_twitter` package to enable Twitter authentication. ```sh flutter pub add firebase_ui_oauth_twitter ``` -------------------------------- ### Bootstrap Project Dependencies with Melos Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md Run the Melos bootstrap command at the root of your local repository to install and link all project dependencies. This command handles local linking without manual `dependency_overrides`. ```bash melos bootstrap ``` -------------------------------- ### Add Google OAuth Package Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/oauth.md Install the `firebase_ui_oauth_google` package using Flutter's package manager. ```sh flutter pub add firebase_ui_oauth_google ``` -------------------------------- ### Install Firebase UI Firestore Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-firestore.md Add the cloud_firestore and firebase_ui_firestore packages to your Flutter project. ```sh flutter pub add cloud_firestore flutter pub add firebase_ui_firestore ``` -------------------------------- ### Add Apple OAuth Package Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/oauth.md Install the `firebase_ui_oauth_apple` package using Flutter's package manager. ```sh flutter pub add firebase_ui_oauth_apple ``` -------------------------------- ### Custom Email Link Sign-In Widget Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/email-link.md Implement `EmailLinkAuthListener` for full control over the authentication lifecycle. This example shows how to manage UI states during the email link sending and sign-in process. ```dart class CustomEmailLinkSignIn extends StatefulWidget { const CustomEmailLinkSignIn({super.key}); @override State createState() => _CustomEmailLinkSignInState(); } class _CustomEmailLinkSignInState extends State implements EmailLinkAuthListener { final auth = FirebaseAuth.instance; late final EmailLinkAuthProvider provider = EmailLinkAuthProvider(actionCodeSettings: actionCodeSettings) ..authListener = this; late Widget child = TextField( decoration: const InputDecoration( labelText: 'Email', ), onSubmitted: provider.sendLink, ); @override void onBeforeLinkSent(String email) { setState(() { child = CircularProgressIndicator(); }); } @override void onLinkSent(String email) { setState(() { child = Text('Check your email and click the link'); }); } @override Widget build(BuildContext context) { return Center(child: child); } @override void onBeforeCredentialLinked(AuthCredential credential) { setState(() { child = CircularProgressIndicator(); }); } @override void onBeforeProvidersForEmailFetch() { setState(() { child = CircularProgressIndicator(); }); } @override void onBeforeSignIn() { setState(() { child = CircularProgressIndicator(); }); } @override void onCanceled() { setState(() { child = Text('Authenticated cancelled'); }); } @override void onCredentialLinked(AuthCredential credential) { Navigator.of(context).pushReplacementNamed('/profile'); } @override void onDifferentProvidersFound( String email, List providers, AuthCredential? credential) { showDifferentMethodSignInDialog( context: context, availableProviders: providers, providers: FirebaseUIAuth.providersFor(FirebaseAuth.instance.app), ); } @override void onError(Object error) { try { // tries default recovery strategy defaultOnAuthError(provider, error); } catch (err) { setState(() { defaultOnAuthError(provider, error); }); } } @override void onSignedIn(UserCredential credential) { Navigator.of(context).pushReplacementNamed('/profile'); } } ``` -------------------------------- ### Install AOT Library on Non-Debug Builds Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Installs the AOT library to the specified destination only when the build type is not 'Debug'. Ensure the AOT_LIBRARY variable is correctly defined. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Custom Stateful Widget for Email Authentication Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/email.md Implement `EmailAuthListener` to gain full control over the authentication lifecycle. This example demonstrates handling various states like before sign-in, credential linking, and errors. ```dart class CustomEmailSignIn extends StatefulWidget { const CustomEmailSignIn({super.key}); @override State createState() => _CustomEmailSignInState(); } class _CustomEmailSignInState extends State implements EmailAuthListener { final auth = FirebaseAuth.instance; late final EmailAuthProvider provider = EmailAuthProvider() ..authListener = this; Widget child = MyCustomEmailForm(onSubmit: (email, password) { provider.authenticate(email, password, AuthAction.signIn); }); @override Widget build(BuildContext context) { return Center(child: child); } @override void onBeforeCredentialLinked(AuthCredential credential) { setState(() { child = CircularProgressIndicator(); }); } @override void onBeforeProvidersForEmailFetch() { setState(() { child = CircularProgressIndicator(); }); } @override void onBeforeSignIn() { setState(() { child = CircularProgressIndicator(); }); } @override void onCanceled() { setState(() { child = MyCustomEmailForm(onSubmit: (email, password) { auth.signInWithEmailAndPassword(email: email, password: password); }); }); } @override void onCredentialLinked(AuthCredential credential) { Navigator.of(context).pushReplacementNamed('/profile'); } @override void onDifferentProvidersFound( String email, List providers, AuthCredential? credential) { showDifferentMethodSignInDialog( context: context, availableProviders: providers, providers: FirebaseUIAuth.providersFor(FirebaseAuth.instance.app), ); } @override void onError(Object error) { try { // tries default recovery strategy defaultOnAuthError(provider, error); } catch (err) { setState(() { defaultOnAuthError(provider, error); }); } } @override void onSignedIn(UserCredential credential) { Navigator.of(context).pushReplacementNamed('/profile'); } } ``` -------------------------------- ### Find System Libraries (CMake) Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required system libraries like GTK, GLIB, and GIO. This is essential for Flutter's Linux desktop integration. Ensure these packages are installed on your system. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md Execute end-to-end tests after starting the Firebase Emulator. These tests communicate directly with Firebase services. ```bash melos test:e2e ``` -------------------------------- ### Configure Routes with EmailVerificationScreen Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/email-verification.md Set up navigation routes in your Flutter app to include the `EmailVerificationScreen`. This example shows how to navigate to the verification screen after a user signs in if their email is not yet verified. ```dart class App extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( initialRoute: FirebaseAuth.instance.currentUser == null ? '/login' : '/profile', routes: { '/login': (context) { return SignInScreen( actions: [ AuthStateChangeAction((context, state) { if (!state.user!.isEmailVerified) { Navigator.pushNamed(context, '/verify-email'); } else { Navigator.pushReplacementNamed(context, '/profile'); } }), ] ); }, '/profile': (context) => ProfileScreen(), '/verify-email': (context) => EmailVerificationScreen( actionCodeSettings: ActionCodeSettings(...), actions: [ EmailVerifiedAction(() { Navigator.pushReplacementNamed(context, '/profile'); }), AuthCancelledAction((context) { FirebaseUIAuth.signOut(context: context); Navigator.pushReplacementNamed(context, '/'); }), ], ), } ) } } ``` -------------------------------- ### Build Custom Progress Indicator with TaskProgressWidget Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-storage/task-progress-indicator.md Extend TaskProgressWidget and override buildProgressIndicator to create your own custom progress indicator. This example shows a simple text-based progress display. ```dart class MyProgressIndicator extends TaskProgressWidget { final Task task; const MyProgressIndicator({super.key, required this.task}); @override Widget buildProgressIndicator(BuildContext context, double progress) { return Text('Progress: ${progress.toStringAsFixed(2)}'); } } ``` -------------------------------- ### Display Download Progress with TaskProgressIndicator Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-storage/task-progress-indicator.md TaskProgressIndicator can also be used to display the progress of a download task. Initialize FirebaseStorage and get a Reference before starting the download. ```dart FirebaseStorage storage = FirebaseStorage.instance; Reference ref = storage.ref('my_file'); DownloadTask task = ref.writeToFile(myFile); TaskProgressIndicator(task: task); ``` -------------------------------- ### Add Dependencies and Include Directories Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/runner/CMakeLists.txt Links necessary libraries and specifies include directories for the application target. Add any custom application-specific dependencies here. ```cmake # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### System Dependencies and PkgConfig Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Finds required system packages using PkgConfig and checks for the GTK+ 3.0 library. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### Define App Routes with Initial Route Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/navigation.md Set up the root route for your application, determining whether to show the sign-in or profile screen based on the current authentication state. This is crucial for applications using named routes. ```dart class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { const providers = [EmailAuthProvider()]; return MaterialApp( initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile', routes: { '/sign-in': (context) => SignInScreen(providers: providers), '/profile': (context) => ProfileScreen(providers: providers), }, ); } } ``` -------------------------------- ### Initialize FirestoreQueryBuilder Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-firestore.md Set up a FirestoreQueryBuilder with a collection query. This is the base for advanced configurations. ```dart final usersQuery = FirebaseFirestore.instance.collection('users').orderBy('name'); FirestoreQueryBuilder>( query: usersQuery, builder: (context, snapshot, _) { // ... TODO! }, ); ``` -------------------------------- ### Initialize Flutter Engine and Run App Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_firestore/example/web/index.html This script initializes the Flutter engine and runs the main application. It's typically used in web applications to load the Flutter entry point. ```javascript var serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, } }).then(function(engineInitializer) { return engineInitializer.initializeEngine(); }).then(function(appRunner) { return appRunner.runApp(); }); }); ``` -------------------------------- ### Load Flutter Engine and Run App Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/web/index.html This JavaScript code initializes the Flutter engine and runs the application. It's essential for web deployment and should be included in your index.html. ```javascript var serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, } }).then(function(engineInitializer) { return engineInitializer.initializeEngine(); }).then(function(appRunner) { return appRunner.runApp(); }); }); ``` -------------------------------- ### Prepare Packages for Release Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md This command versions packages and updates changelogs without creating a Git tag. It's a preparatory step before the final publish. ```bash melos version --no-git-tag-version ``` -------------------------------- ### Install Firebase Dependencies Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/README.md Add the necessary Firebase dependencies to your Flutter project using Flutter's package manager. ```sh flutter pub add firebase_core flutter pub add firebase_auth flutter pub add firebase_ui_auth ``` -------------------------------- ### Implement SignInScreen and navigation actions Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Sets up the MaterialApp with routes for sign-in, profile, and email verification using Firebase UI Auth components. Handles authentication state changes to navigate users accordingly. ```dart import 'package:firebase_ui_auth/firebase_ui_auth.dart'; class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile', routes: { '/sign-in': (context) => SignInScreen( providers: [EmailAuthProvider()], actions: [ AuthStateChangeAction((context, state) { if (!state.user!.isEmailVerified) { Navigator.pushNamed(context, '/verify-email'); } else { Navigator.pushReplacementNamed(context, '/profile'); } }), ForgotPasswordAction((context, email) { Navigator.pushNamed(context, '/forgot-password', arguments: {'email': email}); }), ], ), '/profile': (context) => ProfileScreen( providers: [EmailAuthProvider()], actions: [ SignedOutAction((context) { Navigator.pushReplacementNamed(context, '/sign-in'); }), ], ), '/verify-email': (context) => EmailVerificationScreen( actions: [ EmailVerifiedAction(() { Navigator.pushReplacementNamed(context, '/profile'); }), AuthCancelledAction((context) { FirebaseUIAuth.signOut(context: context); Navigator.pushReplacementNamed(context, '/sign-in'); }), ], ), }, ); } } ``` -------------------------------- ### Add Firebase UI Auth Dependency Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/README.md Add the firebase_ui_auth package to your Flutter project to start using its authentication features. ```sh flutter pub add firebase_ui_auth ``` -------------------------------- ### Initialize Firebase and configure auth providers Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Initializes Firebase and configures supported authentication providers globally for Firebase UI Auth. Ensure to replace 'YOUR_GOOGLE_CLIENT_ID' with your actual Google Client ID. ```dart import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_ui_auth/firebase_ui_auth.dart'; import 'package:firebase_ui_oauth_google/firebase_ui_oauth_google.dart'; import 'firebase_options.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); FirebaseUIAuth.configureProviders([ EmailAuthProvider(), PhoneAuthProvider(), GoogleProvider(clientId: 'YOUR_GOOGLE_CLIENT_ID'), AppleProvider(), ]); runApp(MyApp()); } ``` -------------------------------- ### Set Minimum CMake Version Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/flutter/CMakeLists.txt Specifies the minimum version of CMake required for this project. Ensure your CMake installation meets this requirement. ```cmake cmake_minimum_required(VERSION 3.14) ``` -------------------------------- ### Initialize FirebaseDatabaseQueryBuilder Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-database.md Set up the FirebaseDatabaseQueryBuilder with a database query and a builder function. This is the base for advanced configurations. ```dart final usersQuery = FirebaseDatabase.instance.ref('users').orderByChild('name'); FirebaseDatabaseQueryBuilder( query: usersQuery, builder: (context, snapshot, _) { // ... TODO! }, ); ``` -------------------------------- ### Install Firebase UI for Realtime Database Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-database.md Add the necessary dependencies to your Flutter project to use Firebase UI for Realtime Database. ```sh flutter pub add firebase_database flutter pub add firebase_ui_database ``` -------------------------------- ### Publish Packages to Pub.dev Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md Use this command to publish packages to Pub.dev after a successful dry run and review process. Ensure all tags are pushed to the repository. ```bash melos publish --no-dry-run --git-tag-version ``` -------------------------------- ### Custom Progress Indicator with TaskProgressWidget Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Create custom progress indicators by extending `TaskProgressWidget`. This example shows a percentage-based progress bar. ```dart // Custom progress indicator using TaskProgressWidget class PercentageProgressIndicator extends TaskProgressWidget { final Task task; const PercentageProgressIndicator({super.key, required this.task}); @override Widget buildProgressIndicator(BuildContext context, double progress) { return Row( children: [ Expanded(child: LinearProgressIndicator(value: progress)), const SizedBox(width: 8), Text('${(progress * 100).toStringAsFixed(0)}%'), ], ); } } ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/runner/CMakeLists.txt Applies a standard set of build settings to the application target. This can be modified if the application requires different build configurations. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### EmailLinkAuthProvider - Global Configuration Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Configure the EmailLinkAuthProvider globally by providing ActionCodeSettings. This setup is required before using email link sign-in functionality. ```dart import 'package:firebase_ui_auth/firebase_ui_auth.dart'; // Configuration FirebaseUIAuth.configureProviders([ EmailLinkAuthProvider( actionCodeSettings: ActionCodeSettings( url: 'https://your-project-id.page.link', handleCodeInApp: true, androidMinimumVersion: '1', androidPackageName: 'com.example.myapp', iOSBundleId: 'com.example.myapp', ), ), ]); ``` -------------------------------- ### iOS Info.plist URL Scheme for Google Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/oauth.md Add the necessary URL scheme to your iOS `Info.plist` file to handle Google Sign-In callbacks. ```xml CFBundleURLTypes CFBundleTypeRole Editor CFBundleURLSchemes com.googleusercontent.apps.your-client-id ``` -------------------------------- ### StorageGridView with Custom Grid Delegate Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-storage/grid-view.md Customize the grid layout by providing a custom gridDelegate to StorageGridView. This example uses SliverGridDelegateWithMaxCrossAxisExtent for a maximum cross-axis extent. ```dart StorageGridView( ref: FirebaseStorage.instance.ref('images'), gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 200, mainAxisSpacing: 10, crossAxisSpacing: 10, ), itemBuilder: (context, ref) { return AspectRatio( aspectRatio: 1, child: StorageImage(ref: ref), ); }, ); ``` -------------------------------- ### Theming Input Fields with InputDecorationTheme Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/theming.md Customize the appearance of input fields in `SignInScreen` by overriding `InputDecorationTheme` within `ThemeData`. This example adds an `OutlineInputBorder` to the input fields. ```dart class FirebaseAuthUIExample extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData( inputDecorationTheme: InputDecorationTheme( border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), ), ), ), home: const SignInScreen( providers: [ EmailAuthProvider(), ], ), ); } } ``` -------------------------------- ### Bootstrap with FVM SDK Path Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md If using Flutter Version Management (fvm), specify the SDK path when running the Melos bootstrap command. Replace `/Users/user/fvm/default/` with your actual fvm SDK path. ```bash melos bs --sdk-path=/Users/user/fvm/default/ ``` -------------------------------- ### Applying Standard Build Settings to Target Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Applies the predefined standard compilation settings to the application's executable target. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Theming Firebase UI Widgets Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Customize the appearance of Firebase UI widgets by overriding Flutter's theme properties. This example demonstrates setting a custom `ThemeData` with `InputDecorationTheme` and `OutlinedButtonThemeData`. ```dart import 'package:flutter/material.nimport 'package:firebase_ui_auth/firebase_ui_auth.n class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.indigo), inputDecorationTheme: InputDecorationTheme( border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), ), filled: true, ), outlinedButtonTheme: OutlinedButtonThemeData( style: ButtonStyle( padding: MaterialStateProperty.all( const EdgeInsets.all(16), ), backgroundColor: MaterialStateProperty.all(Colors.indigo), foregroundColor: MaterialStateProperty.all(Colors.white), ), ), ), home: const SignInScreen( providers: [EmailAuthProvider()], ), ); } } ``` -------------------------------- ### Theming Buttons with OutlinedButtonThemeData Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/theming.md Customize the appearance of outlined buttons used in the UI by overriding `OutlinedButtonThemeData` within `ThemeData`. This example sets padding, background color, and foreground color for the buttons. ```dart class FirebaseAuthUIExample extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData( inputDecorationTheme: InputDecorationTheme( border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), ), ), outlinedButtonTheme: OutlinedButtonThemeData( style: ButtonStyle( padding: MaterialStateProperty.all( const EdgeInsets.all(24), ), backgroundColor: MaterialStateProperty.all(Colors.blue), foregroundColor: MaterialStateProperty.all(Colors.white), ), ), ), home: const SignInScreen( providers: [ EmailAuthProvider(), ], ), ); } } ``` -------------------------------- ### Publish Graduated Packages Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md Publish packages to Pub.dev after they have been graduated to a stable version. This command performs the actual publishing. ```bash melos publish --no-dry-run ``` -------------------------------- ### EmailLinkAuthProvider - Routing Setup Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Set up routing for email link sign-in within your MaterialApp. This involves defining routes for the login screen, the email link sign-in screen, and the profile screen. ```dart // Routing setup MaterialApp( routes: { '/login': (context) => SignInScreen( actions: [ EmailLinkSignInAction((context) { Navigator.pushReplacementNamed(context, '/email-link-sign-in'); }), ], ), '/email-link-sign-in': (context) => EmailLinkSignInScreen( actions: [ AuthStateChangeAction((context, state) { Navigator.pushReplacementNamed(context, '/profile'); }), ], ), '/profile': (context) => ProfileScreen(), }, ); ``` -------------------------------- ### Configure Flutter Library Interface Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/windows/flutter/CMakeLists.txt Sets up an INTERFACE library for Flutter, defining include directories and linking the Flutter DLL. This allows other targets to easily depend on Flutter. ```cmake list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Activate FlutterFire CLI Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/README.md Run this command to activate the FlutterFire CLI, which is used for Firebase configuration. ```sh dart pub global activate flutterfire_cli ``` -------------------------------- ### UploadButton Widget for File Picking and Uploading Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Use `UploadButton` to let users pick files (restricted by extensions/mimeTypes) and upload them to Firebase Storage. It provides callbacks for upload start, completion, and errors. ```dart import 'package:firebase_ui_storage/firebase_ui_storage.dart'; class MyUploadWidget extends StatelessWidget { const MyUploadWidget({super.key}); @override Widget build(BuildContext context) { UploadTask? task; return StatefulBuilder(builder: (context, setState) { // Show progress indicator while uploading if (task != null) return TaskProgressIndicator(task: task!); return UploadButton( // Restrict to images only extensions: ['jpg', 'jpeg', 'png', 'webp'], mimeTypes: ['image/jpeg', 'image/png', 'image/webp'], variant: ButtonVariant.filled, onUploadStarted: (t) => setState(() => task = t), onUploadComplete: (ref) { setState(() => task = null); ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Uploaded: ${ref.fullPath}')), ); }, onError: (e, stackTrace) { setState(() => task = null); ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Upload failed: $e')), ); }, ); }); } } ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Adds definitions to ensure all projects use Unicode character encoding. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Create Flutter Wrapper Plugin Library Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/flutter/CMakeLists.txt Builds a static library for the Flutter plugin wrapper. This library includes core and plugin-specific wrapper sources and links against the Flutter library. ```cmake add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Export Flutter Library and ICU Data Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/flutter/CMakeLists.txt Makes the Flutter library path and ICU data file available to the parent scope for installation or further processing. PARENT_SCOPE ensures visibility outside the current directory. ```cmake set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) ``` -------------------------------- ### Custom Routing with AuthStateChangeAction Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Intercept authentication state transitions to integrate with named routes or custom navigation. This example shows how to navigate to different screens based on sign-in, sign-out, and forgot password events. ```dart import 'package:firebase_ui_auth/firebase_ui_auth.nimport 'package:flutter/material.n'; class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { const providers = [EmailAuthProvider()]; return MaterialApp( initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile', routes: { '/sign-in': (context) => SignInScreen( providers: providers, actions: [ // Navigate to profile on sign-in AuthStateChangeAction((context, _) { Navigator.pushReplacementNamed(context, '/profile'); }), // Override forgot-password navigation ForgotPasswordAction((context, email) { Navigator.pushNamed(context, '/forgot-password', arguments: {'email': email}); }), ], ), '/profile': (context) => ProfileScreen( providers: providers, actions: [ // Navigate back to sign-in on sign-out SignedOutAction((context) { Navigator.pushReplacementNamed(context, '/sign-in'); }), ], ), '/forgot-password': (context) => ForgotPasswordScreen( actions: [ AuthStateChangeAction((context, _) { Navigator.pop(context); }), ], ), }, ); } } ``` -------------------------------- ### Configure FirebaseUIStorage Globally Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Set up global upload root and naming policy for all FirebaseUI Storage widgets. Ensure Firebase is initialized before calling this. ```dart import 'package:firebase_storage/firebase_storage.dart'; import 'package:firebase_ui_storage/firebase_ui_storage.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); final storage = FirebaseStorage.instance; await FirebaseUIStorage.configure( FirebaseUIStorageConfiguration( storage: storage, uploadRoot: storage.ref('user-uploads'), // UuidFileUploadNamingPolicy: generates UUID filenames // KeepOriginalNameUploadPolicy: keeps original filename (default) // KeepPathUploadPolicy: keeps full original path namingPolicy: UuidFileUploadNamingPolicy(), ), ); runApp(MyApp()); } ``` -------------------------------- ### OAuth Providers Configuration for Firebase UI Flutter Source: https://context7.com/firebase/firebaseui-flutter/llms.txt Configures OAuth providers like Google, Apple, Facebook, and Twitter for sign-in. Requires installing provider-specific packages and setting up client IDs or API keys. ```dart // Install packages: // flutter pub add firebase_ui_oauth_google // flutter pub add firebase_ui_oauth_apple // flutter pub add firebase_ui_oauth_facebook // flutter pub add firebase_ui_oauth_twitter import 'package:firebase_ui_oauth_google/firebase_ui_oauth_google.dart'; import 'package:firebase_ui_oauth_apple/firebase_ui_oauth_apple.dart'; import 'package:firebase_ui_oauth_facebook/firebase_ui_oauth_facebook.dart'; import 'package:firebase_ui_oauth_twitter/firebase_ui_oauth_twitter.dart'; // Platform-aware Google client ID const iOSClientId = 'your-ios-client-id.apps.googleusercontent.com'; const webClientId = 'your-web-client-id.apps.googleusercontent.com'; String get googleClientId { return switch (defaultTargetPlatform) { TargetPlatform.iOS || TargetPlatform.macOS => iOSClientId, _ => webClientId, }; } FirebaseUIAuth.configureProviders([ GoogleProvider(clientId: googleClientId), AppleProvider(), FacebookProvider(clientId: 'YOUR_FACEBOOK_APP_ID'), TwitterProvider( apiKey: 'YOUR_TWITTER_API_KEY', apiSecretKey: String.fromEnvironment('TWITTER_SECRET', defaultValue: ''), ), ]); // OAuth button on a custom screen class MyCustomSignInScreen extends StatelessWidget { @override Widget build(BuildContext context) { return AuthStateListener( listener: (oldState, newState, ctrl) { if (newState is SignedIn) { Navigator.pushReplacementNamed(context, '/profile'); } return null; }, child: Column( children: [ OAuthProviderButton(provider: GoogleProvider(clientId: googleClientId)), OAuthProviderButton(provider: AppleProvider()), OAuthProviderButton(provider: FacebookProvider(clientId: 'YOUR_FACEBOOK_APP_ID')), ], ), ); } } ``` -------------------------------- ### Flutter Tool Backend Custom Command (CMake) Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/flutter/CMakeLists.txt Configures a custom command to run the Flutter tool backend script. This command is designed to execute every time by using a dummy output file `_phony_`, as there's no direct way to determine all inputs/outputs for the Flutter tool. It sets up the environment and passes build parameters. ```cmake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) ``` -------------------------------- ### Override Forgot Password Navigation Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/navigation.md Customize the navigation triggered by the 'Forgot Password' button within the `SignInScreen`. This example demonstrates navigating to a custom '/forgot-password' named route, passing the user's email as an argument. ```dart class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { const providers = [EmailAuthProvider()]; return MaterialApp( initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile', routes: { '/sign-in': (context) { return SignInScreen( providers: providers, actions: [ ForgotPasswordAction((context, email) { Navigator.of(context).pushNamed( '/forgot-password', arguments: {'email': email}, ); }), ], ); }, '/profile': (context) => ProfileScreen(providers: providers), '/forgot-password': (context) => MyCustomForgotPasswordScreen(), }, ); } } ``` -------------------------------- ### Cross-Building System Root Configuration Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Configures CMake for cross-building by setting the target system root and related find root path modes. ```cmake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### Add License Headers to Files Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md Run this Melos command to automatically add the required license header to all necessary files in the repository. This ensures compliance with licensing requirements. ```bash melos run add-license-header ``` -------------------------------- ### Graduate Packages to Stable Version Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md Use this command to graduate packages from development to stable versions. It prompts for packages to be graduated and can be scoped to specific packages. ```bash melos version --graduate ``` ```bash melos version --graduate --scope="*firestore*" ``` -------------------------------- ### Create Flutter Wrapper Application Library Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/flutter/CMakeLists.txt Builds a static library for the Flutter application wrapper. This library includes core and application-specific wrapper sources and links against the Flutter library. ```cmake add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Initialize Flutter Web App with Service Worker Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/web/index.html This script loads the main Dart entrypoint for a Flutter web application. It configures the service worker and initializes the Flutter engine upon successful entrypoint loading. ```javascript const serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Using SignInScreen with Email Verification Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/email.md Integrate the SignInScreen and handle email verification logic. Navigate users to a verification screen if their email is not yet verified after signing in. ```dart SignInScreen( actions: [ AuthStateChangeAction((context, state) { if (!state.user!.isEmailVerified) { Navigator.pushNamed(context, '/verify-email'); } else { Navigator.pushReplacementNamed(context, '/profile'); } }), ], ); ``` -------------------------------- ### Include Generated Plugin Rules Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Includes the CMake script that manages building and adding generated plugins to the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Format Code with Melos Source: https://github.com/firebase/firebaseui-flutter/blob/main/CONTRIBUTING.md Run this command to format your code according to project standards. Ensure your code is formatted before committing. ```bash melos run format ``` -------------------------------- ### Define Application Wrapper Sources Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/flutter/CMakeLists.txt Lists the C++ source files for the Flutter application wrapper. These are used when building the main application executable that hosts the Flutter engine. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Configure Flutter Library and Paths (CMake) Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/flutter/CMakeLists.txt Sets up essential Flutter library paths and variables, including the main Flutter library, ICU data file, project build directory, and AOT library. These are published to the parent scope for use in other build steps. ```cmake set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) ``` -------------------------------- ### Using SignInScreen with Phone Authentication Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/phone.md Integrate the SignInScreen to automatically include a button for phone number authentication after configuring PhoneAuthProvider. Use VerifyPhoneAction to handle the navigation to the phone number input screen. ```dart SignInScreen( actions: [ VerifyPhoneAction((context, _) { Navigator.pushNamed(context, '/phone'); }), ], ); ``` -------------------------------- ### Handle Loading and Error States Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-database.md Implement logic within the builder to display a loading indicator or an error message based on the snapshot's state. ```dart FirebaseDatabaseQueryBuilder( query: usersQuery, builder: (context, snapshot, _) { if (snapshot.isFetching) { return const CircularProgressIndicator(); } if (snapshot.hasError) { return Text('Something went wrong! ${snapshot.error}'); } // ... }, ); ``` -------------------------------- ### Custom Initial Page Loading State Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-storage/list-view.md Customize the UI displayed while the first page of objects is loading by providing a `loadingBuilder`. This allows for a custom loading indicator or message. ```dart StorageListView( ref: FirebaseStorage.instance.ref('images'), loadingBuilder: (context) { return Center( child: Text('Loading...'), ); }, itemBuilder: (context, ref) { return AspectRatio( aspectRatio: 1, child: StorageImage(ref: ref), ); }, ); ``` -------------------------------- ### Handle Successful Sign-In with Named Routes Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/navigation.md Override the default sign-in action to navigate to a specific named route, such as '/profile', upon successful authentication. This is necessary when not explicitly subscribing to authentication state changes. ```dart SignInScreen( actions: [ AuthStateChangeAction((context, _) { Navigator.of(context).pushReplacementNamed('/profile'); }), ], // ... ) ``` -------------------------------- ### Configure Facebook Provider Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/oauth.md Configure the Facebook provider by initializing Firebase and adding `FacebookProvider` with your `FACEBOOK_CLIENT_ID` to `FirebaseUIAuth`. ```dart Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); FirebaseUIAuth.configureProviders([ FacebookProvider(clientId: FACEBOOK_CLIENT_ID), ]); } ``` -------------------------------- ### Configure Google Provider Source: https://github.com/firebase/firebaseui-flutter/blob/main/docs/firebase-ui-auth/providers/oauth.md Initialize Firebase UI with the Google provider, setting the `clientId` obtained from the Firebase Console. This ensures seamless cross-platform support. ```dart Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); FirebaseUIAuth.configureProviders([ GoogleProvider(clientId: GOOGLE_CLIENT_ID), ]); } ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/firebase/firebaseui-flutter/blob/main/packages/firebase_ui_auth/example/windows/CMakeLists.txt Specifies the minimum required CMake version and names the CXX project. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Application Target Definition Source: https://github.com/firebase/firebaseui-flutter/blob/main/tests/linux/CMakeLists.txt Defines the main executable target for the application, listing its source files. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ```