### Configure Installation Paths and Rules Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_storage/firebase_storage/example/windows/CMakeLists.txt Sets up installation directories and defines rules for installing the executable, library files, and assets. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. 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}") 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(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Installation and Setup Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/README.md Instructions for installing and configuring the Firebase FlutterFire SDK for your Flutter project. ```APIDOC ## Installation ```sh flutter pub get firebase_data_connect flutterfire configure ``` For more information, see [Flutter for Firebase installation documentation](https://firebase.google.com/docs/data-connect/flutter-sdk#use-core). ``` -------------------------------- ### Configure Installation Paths Source: https://github.com/firebase/flutterfire/blob/main/tests/windows/CMakeLists.txt Sets up installation directories and default build behavior for the application bundle. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. 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}") ``` -------------------------------- ### Install FlutterFire SDK Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/README.md Run these commands to get the firebase_data_connect package and configure FlutterFire for your project. ```sh flutter pub get firebase_data_connect flutterfire configure ``` -------------------------------- ### Configure Installation Directory for Visual Studio Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_remote_config/firebase_remote_config/example/windows/CMakeLists.txt Sets up installation directories and makes the 'install' step default for Visual Studio builds. This ensures the application runs correctly from Visual Studio. ```cmake # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. 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}") ``` -------------------------------- ### Run Firebase Auth Example Source: https://github.com/firebase/flutterfire/blob/main/CONTRIBUTING.md Navigate to the example directory for Firebase Auth and run the example application using `flutter run`. ```bash cd packages/firebase_auth/firebase_auth/example flutter run ``` -------------------------------- ### Install Application Executable Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/pipeline_example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Paths Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/pipeline_example/windows/CMakeLists.txt Sets up installation directories for runtime components, ensuring support files are placed next to the executable. ```cmake set(BUILD_BUNDLE_DIR "$") 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}") ``` -------------------------------- ### Install addlicense Tool Source: https://github.com/firebase/flutterfire/blob/main/CONTRIBUTING.md Install the `addlicense` tool using Go, which is used to add license headers to new files in the repository. ```bash go install github.com/google/addlicense@latest ``` -------------------------------- ### Configure Installation Paths Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_core/firebase_core/example/windows/CMakeLists.txt Sets up installation directories for the application bundle, data, and libraries. Ensures files are placed correctly next to the executable. ```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}") ``` -------------------------------- ### Install Application and Assets Source: https://github.com/firebase/flutterfire/blob/main/tests/windows/CMakeLists.txt Defines installation rules for the executable, libraries, and Flutter assets, including cleanup of stale files. ```cmake 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(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # 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) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Full Cloud Storage reference example Source: https://github.com/firebase/flutterfire/blob/main/docs/storage/create-reference.md This example demonstrates creating a root reference, deriving child references using paths and variables, accessing file properties, and navigating back up the hierarchy. ```dart // Points to the root reference final storageRef = FirebaseStorage.instance.ref(); // Points to "images" Reference? imagesRef = storageRef.child("images"); // Points to "images/space.jpg" // Note that you can use variables to create child values final fileName = "space.jpg"; final spaceRef = imagesRef.child(fileName); // File path is "images/space.jpg" final path = spaceRef.fullPath; // File name is "space.jpg" final name = spaceRef.name; // Points to "images" imagesRef = spaceRef.parent; ``` -------------------------------- ### Start Firebase Emulator Source: https://github.com/firebase/flutterfire/blob/main/CONTRIBUTING.md Run this command to start the Firebase Emulator Suite for testing. Ensure you are in the correct directory. ```bash cd .github/workflows/scripts melos run firebase:emulator ``` -------------------------------- ### Install Flutter Library Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/pipeline_example/windows/CMakeLists.txt Installs the main Flutter library file to the root of the application bundle. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Application Target and Support Files Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_remote_config/firebase_remote_config/example/windows/CMakeLists.txt Installs the main application executable, ICU data, Flutter library, and bundled plugin libraries. This prepares the application for runtime. ```cmake 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(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Application Target and Core Files Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_core/firebase_core/example/windows/CMakeLists.txt Installs the main application executable, ICU data file, and the Flutter library. These are essential runtime components. ```cmake 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(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Dynamic Link domain URI prefix examples Source: https://github.com/firebase/flutterfire/blob/main/docs/dynamic-links/create.md Examples of valid Dynamic Link domain URL prefixes. ```text https://example.com/link https://example.page.link ``` -------------------------------- ### Set installation directory for bundled libraries Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_auth/firebase_auth/example/windows/CMakeLists.txt Defines the installation path for bundled libraries, usually at the root of the installation prefix. This ensures libraries are accessible to the application. ```cmake set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Application Runtime Files Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_app_check/firebase_app_check/example/windows/CMakeLists.txt Configures the installation of the main executable, ICU data, Flutter library, bundled plugin libraries, and native assets. Ensures files are placed correctly for runtime execution. ```cmake set(BUILD_BUNDLE_DIR "$") 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}") 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(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) 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(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/pipeline_example/windows/CMakeLists.txt Installs any bundled native libraries provided by plugins to the application bundle. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Read user data once using get() Source: https://github.com/firebase/flutterfire/blob/main/docs/database/read-and-write.md Use `get()` to retrieve a snapshot of data from the database for one-time access. Avoid unnecessary use of `get()` as it can increase bandwidth usage and reduce performance. ```dart final ref = FirebaseDatabase.instance.ref(); final snapshot = await ref.child('users/$userId').get(); if (snapshot.exists) { print(snapshot.value); } else { print('No data available.'); } ``` -------------------------------- ### Install Assets and AOT Library Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_storage/firebase_storage/example/windows/CMakeLists.txt Handles the removal of stale assets and installation of the AOT library for non-debug builds. ```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) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install FlutterFire CLI Source: https://github.com/firebase/flutterfire/blob/main/docs/setup/_setup_main.md Install the FlutterFire CLI globally using the Dart package manager. ```sh dart pub global activate flutterfire_cli ``` -------------------------------- ### Install AOT Library Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/pipeline_example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library for non-Debug builds (Profile and Release). ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Complete multi-factor sign-in flow Source: https://github.com/firebase/flutterfire/blob/main/docs/auth/multi-factor.md A comprehensive example demonstrating the full multi-factor sign-in process from initial authentication to final resolution. ```dart try { await _auth.signInWithEmailAndPassword( email: emailController.text, password: passwordController.text, ); } on FirebaseAuthMultiFactorException catch (e) { setState(() { error = '${e.message}'; }); final firstHint = e.resolver.hints.first; if (firstHint is! PhoneMultiFactorInfo) { return; } await FirebaseAuth.instance.verifyPhoneNumber( multiFactorSession: e.resolver.session, multiFactorInfo: firstHint, verificationCompleted: (_) {}, verificationFailed: (_) {}, codeSent: (String verificationId, int? resendToken) async { // See `firebase_auth` example app for a method of retrieving user's sms code: // https://github.com/firebase/flutterfire/blob/main/packages/firebase_auth/firebase_auth/example/lib/auth.dart#L591 final smsCode = await getSmsCodeFromUser(context); if (smsCode != null) { // Create a PhoneAuthCredential with the code final credential = PhoneAuthProvider.credential( verificationId: verificationId, smsCode: smsCode, ); try { await e.resolver.resolveSignIn( PhoneMultiFactorGenerator.getAssertion( credential, ), ); } on FirebaseAuthException catch (e) { print(e.message); } } }, codeAutoRetrievalTimeout: (_) {}, ); } catch (e) { ... } ``` -------------------------------- ### Install Firebase Authentication Plugin Source: https://github.com/firebase/flutterfire/blob/main/docs/auth/start.md Run this command in the root of your Flutter project to add the dependency. ```bash flutter pub add firebase_auth ``` -------------------------------- ### Install AOT Library for Release Builds Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_remote_config/firebase_remote_config/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library on non-Debug builds (Profile and Release). This optimizes application startup performance. ```cmake # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_remote_config/firebase_remote_config/example/windows/CMakeLists.txt Installs the Flutter assets directory, ensuring it's copied correctly and that stale files are removed on each build. This is critical for the application's UI and resources. ```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) ``` -------------------------------- ### Install Performance Monitoring plugin Source: https://github.com/firebase/flutterfire/blob/main/docs/perf-mon/get-started.md Use the Flutter CLI to add the firebase_performance package to your project dependencies. ```sh flutter pub add firebase_performance ``` -------------------------------- ### Install ICU Data File Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/pipeline_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) ``` -------------------------------- ### Complete MFA Enrollment Workflow Source: https://github.com/firebase/flutterfire/blob/main/docs/auth/multi-factor.md A comprehensive example demonstrating the full flow of retrieving a session, verifying a phone number, and enrolling the factor. ```dart final session = await user.multiFactor.getSession(); final auth = FirebaseAuth.instance; await auth.verifyPhoneNumber( multiFactorSession: session, phoneNumber: phoneController.text, verificationCompleted: (_) {}, verificationFailed: (_) {}, codeSent: (String verificationId, int? resendToken) async { // See `firebase_auth` example app for a method of retrieving user's sms code: // https://github.com/firebase/flutterfire/blob/main/packages/firebase_auth/firebase_auth/example/lib/auth.dart#L591 final smsCode = await getSmsCodeFromUser(context); if (smsCode != null) { // Create a PhoneAuthCredential with the code final credential = PhoneAuthProvider.credential( verificationId: verificationId, smsCode: smsCode, ); try { await user.multiFactor.enroll( PhoneMultiFactorGenerator.getAssertion( credential, ), ); } on FirebaseAuthException catch (e) { print(e.message); } } }, codeAutoRetrievalTimeout: (_) {}, ); ``` -------------------------------- ### Log a Predefined Checkout Event Source: https://github.com/firebase/flutterfire/blob/main/docs/analytics/_get-started.md Log a `logBeginCheckout` event with associated parameters such as value, currency, items, and coupon. This is an example of logging a recommended event. ```dart await FirebaseAnalytics.instance .logBeginCheckout( value: 10.0, currency: 'USD', items: [ AnalyticsEventItem( itemName: 'Socks', itemId: 'xjw73ndnw', price: '10.0' ), ], coupon: '10PERCENTOFF' ); ``` -------------------------------- ### Getting the Ref Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/README.md Demonstrates how to obtain a `Ref` object from a builder, which can then be used to execute the underlying operation. ```APIDOC ## General Ref Usage ### Description Each builder returns an `execute` function, which is a helper function that creates a `Ref` object, and executes the underlying operation. ### Method GET (or relevant method for the builder) ### Endpoint N/A (Conceptual - used with specific builders) ### Parameters - None directly for getting the ref, but depends on the builder context. ### Request Example ```dart final ref = MoviesConnector.instance.thing().ref(); ref.execute(); ``` ### Response - The `ref` object allows for execution of the operation. ### Response Example ```dart final ref = MoviesConnector.instance.thing().ref(); ref.execute(); ``` ``` -------------------------------- ### Install Native Assets Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/pipeline_example/windows/CMakeLists.txt Copies native assets provided by build.dart from all packages to the application bundle. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Run Flutter Web App on Port 5000 Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_auth/firebase_auth/example/README.md Use this command to run the Flutter web example on port 5000, which is required for Google authentication. ```bash flutter run -d web-server --web-port 5000 ``` -------------------------------- ### Set installation directory for bundled data Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_auth/firebase_auth/example/windows/CMakeLists.txt Defines the installation path for bundled data files, typically within the application's data directory. This ensures assets are correctly placed at runtime. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") ``` -------------------------------- ### Define CORS Configuration File Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_storage/firebase_storage_web/README.md Example of a cors.json file content required to allow cross-origin requests. ```json [ { "origin": ["*"], "method": ["GET"], "maxAgeSeconds": 3600 } ] ``` -------------------------------- ### Install Remote Config and Analytics Plugins Source: https://github.com/firebase/flutterfire/blob/main/docs/remote-config/_get-started.md Commands to add the necessary Firebase dependencies to your Flutter project. ```bash flutter pub add firebase_remote_config ``` ```bash flutter pub add firebase_analytics ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/pipeline_example/windows/CMakeLists.txt Removes the existing Flutter assets directory and then copies the new assets to the data directory, ensuring up-to-date assets on each build. ```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) ``` -------------------------------- ### Define a basic user profile JSON structure Source: https://github.com/firebase/flutterfire/blob/main/docs/database/structure-data.md Example of a user profile entry within a JSON tree structure. ```json { "users": { "alovelace": { "name": "Ada Lovelace", "contacts": { "ghopper": true }, }, "ghopper": { ... }, "eclarke": { ... } } } ``` -------------------------------- ### Create a root Cloud Storage reference Source: https://github.com/firebase/flutterfire/blob/main/docs/storage/create-reference.md Use the `FirebaseStorage.instance.ref()` method to get a reference to the root of your Cloud Storage bucket. This is the starting point for accessing any file. ```dart final storageRef = FirebaseStorage.instance.ref(); ``` -------------------------------- ### Handle Notification Interaction in Flutter Source: https://github.com/firebase/flutterfire/blob/main/docs/cloud-messaging/client.md Use `getInitialMessage` for terminated app states and `onMessageOpenedApp` for background states to handle notification interactions. This example demonstrates a basic setup within a `StatefulWidget`. ```dart import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(const MyApp()); } class MyApp extends StatefulWidget { const MyApp({super.key}); @override State createState() => _MyAppState(); } class _MyAppState extends State with WidgetsBindingObserver { static final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; @override void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); // Get initial message if app was opened from a terminated state _firebaseMessaging.getInitialMessage().then((RemoteMessage* message) { if (message != null) { // Handle the notification message print("App opened from terminated state with message: ${message.messageId}"); } }); // Listen for messages when the app is in the foreground FirebaseMessaging.onMessage.listen((RemoteMessage message) { print('Got a message whilst in the foreground!'); print('Message data: ${message.data}'); if (message.notification != null) { print('Message also contained a notification: ${message.notification!.title}, ${message.notification!.body}'); } }); // Listen for messages when the app is opened from a background state _firebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { print('App opened from background state with message: ${message.messageId}'); // Handle the notification message }); } @override void dispose() { WidgetsBinding.instance.removeObserver(this); super.dispose(); } @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headlineMedium, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), ); } } ``` -------------------------------- ### Start ChromeDriver for Web Tests Source: https://github.com/firebase/flutterfire/blob/main/CONTRIBUTING.md Initiate the ChromeDriver process on port 4444, which is necessary for running end-to-end tests in web environments. ```bash chromedriver --port=4444 ``` -------------------------------- ### Install Firebase Realtime Database Plugin Source: https://github.com/firebase/flutterfire/blob/main/docs/database/start.md Run this command in your Flutter project's root directory to add the firebase_database plugin. ```bash flutter pub add firebase_database ``` -------------------------------- ### Set Custom Attribute Example Source: https://github.com/firebase/flutterfire/blob/main/docs/perf-mon/_custom-code-traces.md Example of setting a valid custom attribute on a trace. ```dart customTrace.putAttribute("experiment", "A"); // OK ``` -------------------------------- ### Invalid Custom Attribute Example Source: https://github.com/firebase/flutterfire/blob/main/docs/perf-mon/_custom-code-traces.md Example of an invalid custom attribute containing personally identifiable information. ```dart customTrace.putAttribute(("email", user.getEmailAddress()); // Don't do this! ``` -------------------------------- ### Create a new user account with email and password Source: https://github.com/firebase/flutterfire/blob/main/docs/auth/password-auth.md Use this method to register new users. Successful creation automatically signs the user in. ```dart try { final credential = await FirebaseAuth.instance.createUserWithEmailAndPassword( email: emailAddress, password: password, ); } on FirebaseAuthException catch (e) { if (e.code == 'weak-password') { print('The password provided is too weak.'); } else if (e.code == 'email-already-in-use') { print('The account already exists for that email.'); } } catch (e) { print(e); } ``` -------------------------------- ### Connecting to the Emulator Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/README.md How to connect the Data Connect instance to a local emulator for development and testing. ```APIDOC ## Data Connect instance ### Connecting to the emulator ```dart String host = 'localhost'; // or your host name int port = 9399; // or your port number MoviesConnector.instance.dataConnect.useDataConnectEmulator(host, port); ``` ``` -------------------------------- ### Configure Flutter Windows Build Environment Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/pipeline_example/windows/flutter/CMakeLists.txt Sets up the ephemeral directory, includes generated configurations, and defines fallback platform targets. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Configure Light Theme with Material 3 Source: https://github.com/firebase/flutterfire/blob/main/GEMINI.md Set up a light theme using ThemeData and ColorScheme.fromSeed for harmonious color generation. Integrates Google Fonts for typography. ```dart final ThemeData lightTheme = ThemeData( colorScheme: ColorScheme.fromSeed( seedColor: Colors.deepPurple, brightness: Brightness.light, ), textTheme: GoogleFonts.outfitTextTheme(), ); ``` -------------------------------- ### Install Native Assets Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_remote_config/firebase_remote_config/example/windows/CMakeLists.txt Installs native assets provided by build.dart from all packages into the application bundle. This ensures all necessary native resources are included. ```cmake # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configure Flutter Windows Build Environment Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_remote_config/firebase_remote_config/example/windows/flutter/CMakeLists.txt Sets up the ephemeral directory, includes generated configurations, and defines the Flutter library path. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # 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/windows/app.so" PARENT_SCOPE) 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) ``` -------------------------------- ### Implement Full Upload with Progress Monitoring in Dart Source: https://github.com/firebase/flutterfire/blob/main/docs/storage/upload-files.md A complete implementation showing file metadata setup, task initiation, and detailed progress tracking via snapshot events. ```dart final appDocDir = await getApplicationDocumentsDirectory(); final filePath = "${appDocDir.absolute}/path/to/mountains.jpg"; final file = File(filePath); // Create the file metadata final metadata = SettableMetadata(contentType: "image/jpeg"); // Create a reference to the Firebase Storage bucket final storageRef = FirebaseStorage.instance.ref(); // Upload file and metadata to the path 'images/mountains.jpg' final uploadTask = storageRef .child("images/path/to/mountains.jpg") .putFile(file, metadata); // Listen for state changes, errors, and completion of the upload. uploadTask.snapshotEvents.listen((TaskSnapshot taskSnapshot) { switch (taskSnapshot.state) { case TaskState.running: final progress = 100.0 * (taskSnapshot.bytesTransferred / taskSnapshot.totalBytes); print("Upload is $progress% complete."); break; case TaskState.paused: print("Upload is paused."); break; case TaskState.canceled: print("Upload was canceled"); break; case TaskState.error: // Handle unsuccessful uploads break; case TaskState.success: // Handle successful uploads on complete // ... break; } }); ``` -------------------------------- ### Configure Unit Tests Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/windows/CMakeLists.txt Sets up Google Test and defines the test executable for the plugin. ```cmake # === Tests === # These unit tests can be run from a terminal after building the example, or # from Visual Studio after opening the generated solution file. # Only enable test builds when building the example (which sets this variable) # so that plugin clients aren't building the tests. if (${include_${PROJECT_NAME}_tests}) set(TEST_RUNNER "${PROJECT_NAME}_test") enable_testing() # Add the Google Test dependency. include(FetchContent) FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/release-1.11.0.zip ) # Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # Disable install commands for gtest so it doesn't end up in the bundle. set(INSTALL_GTEST OFF CACHE BOOL "Disable installation of googletest" FORCE) FetchContent_MakeAvailable(googletest) # The plugin's C API is not very useful for unit testing, so build the sources # directly into the test binary rather than using the DLL. add_executable(${TEST_RUNNER} test/cloud_firestore_plugin_test.cpp ${PLUGIN_SOURCES} ) apply_standard_settings(${TEST_RUNNER}) target_include_directories(${TEST_RUNNER} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_link_libraries(${TEST_RUNNER} PRIVATE flutter_wrapper_plugin) target_link_libraries(${TEST_RUNNER} PRIVATE gtest_main gmock) # flutter_wrapper_plugin has link dependencies on the Flutter DLL. add_custom_command(TARGET ${TEST_RUNNER} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${FLUTTER_LIBRARY}" $ ) ``` -------------------------------- ### Install Firebase App Check SDK Source: https://github.com/firebase/flutterfire/blob/main/docs/app-check/default-providers.md Install the firebase_app_check plugin using flutter pub add. This command adds the necessary dependency to your project. ```bash flutter pub add firebase_app_check ``` -------------------------------- ### Create a Cloud Storage reference Source: https://github.com/firebase/flutterfire/blob/main/docs/storage/download-files.md Create references using child paths or existing Google Cloud Storage/HTTPS URLs. ```dart // Create a storage reference from our app final storageRef = FirebaseStorage.instance.ref(); // Create a reference with an initial file path and name final pathReference = storageRef.child("images/stars.jpg"); // Create a reference to a file from a Google Cloud Storage URI final gsReference = FirebaseStorage.instance.refFromURL("gs://YOUR_BUCKET/images/stars.jpg"); // Create a reference from an HTTPS URL // Note that in the URL, characters are URL escaped! final httpsReference = FirebaseStorage.instance.refFromURL( "https://firebasestorage.googleapis.com/b/YOUR_BUCKET/o/images%20stars.jpg"); ``` -------------------------------- ### Add Firebase Storage SDK to Flutter app Source: https://github.com/firebase/flutterfire/blob/main/docs/storage/start.md Install the Firebase Storage plugin using the Flutter package manager. After installation, rebuild your application to apply the changes. ```bash flutter pub add firebase_storage ``` -------------------------------- ### Set Target Properties and Dependencies Source: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/windows/CMakeLists.txt Configures visibility, compile definitions, and links necessary libraries. ```cmake # Symbols are hidden by default to reduce the chance of accidental conflicts # between plugins. This should not be removed; any symbols that should be # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro. set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) target_compile_definitions(${PLUGIN_NAME} PUBLIC FLUTTER_PLUGIN_IMPL) # Enable firebase-cpp-sdk's platform logging api. target_compile_definitions(${PLUGIN_NAME} PRIVATE -DINTERNAL_EXPERIMENTAL=1) # Source include directories and library dependencies. Add any plugin-specific # dependencies here. set(MSVC_RUNTIME_MODE MD) set(firebase_libs firebase_core_plugin firebase_auth firebase_firestore) set(ADDITIONAL_LIBS advapi32 ws2_32 crypt32 rpcrt4 ole32 shell32 Bcrypt.lib DbgHelp.lib) target_link_libraries(${PLUGIN_NAME} PRIVATE "${firebase_libs}" "${ADDITIONAL_LIBS}") # Source include directories and library dependencies. Add any plugin-specific # dependencies here. target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) # List of absolute paths to libraries that should be bundled with the plugin. # This list could contain prebuilt libraries, or libraries created by an # external build triggered from this build file. set(cloud_firestore_bundled_libraries "" PARENT_SCOPE ) ``` -------------------------------- ### Configure Plugin Include Directories and Linking Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_core/firebase_core/windows/CMakeLists.txt Sets include directories and links the plugin against Flutter libraries. ```cmake target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PUBLIC flutter flutter_wrapper_plugin) ``` -------------------------------- ### Start and Stop a Custom Code Trace Source: https://github.com/firebase/flutterfire/blob/main/docs/perf-mon/_custom-code-traces.md Wrap the code you want to trace with start() and stop() methods of a Trace object. Ensure trace names meet specific requirements: no leading/trailing whitespace, no leading underscore, and max 100 characters. ```dart Trace customTrace = FirebasePerformance.instance.newTrace('custom-trace'); await customTrace.start(); // Code you want to trace await customTrace.stop(); ``` -------------------------------- ### Sign in with Google using Popup on Web Source: https://github.com/firebase/flutterfire/blob/main/docs/auth/federated-auth.md Initiate Google sign-in on the web using `signInWithPopup`, which opens a new window for user authentication. Ensure the GoogleAuthProvider is configured beforehand. ```dart Future signInWithGoogle() async { // Create a new provider GoogleAuthProvider googleProvider = GoogleAuthProvider(); googleProvider.addScope('https://www.googleapis.com/auth/contacts.readonly'); googleProvider.setCustomParameters({ 'login_hint': 'user@example.com' }); // Once signed in, return the UserCredential return await FirebaseAuth.instance.signInWithPopup(googleProvider); // Or use signInWithRedirect // return await FirebaseAuth.instance.signInWithRedirect(googleProvider); } ``` -------------------------------- ### Add Custom Network Request Trace in Flutter Source: https://github.com/firebase/flutterfire/blob/main/docs/perf-mon/_custom-network-traces.md Use the HttpMetric API to start and stop a custom trace for a network request. This requires importing the necessary Firebase Performance and http packages. Ensure the metric is started before the request and stopped after the response is received. ```dart final metric = FirebasePerformance.instance .newHttpMetric("https://www.google.com", HttpMethod.Get); await metric.start(); final response = await http.get(Uri.parse("https://www.google.com/")); await metric.stop(); ``` -------------------------------- ### Bootstrap Project Dependencies with Melos Source: https://github.com/firebase/flutterfire/blob/main/CONTRIBUTING.md Bootstrap the project dependencies using Melos at the root of your local clone. This command locally links all dependencies without manual overrides. ```bash melos bootstrap ``` -------------------------------- ### Get a DatabaseReference Source: https://github.com/firebase/flutterfire/blob/main/docs/database/lists-of-data.md Obtain an instance of DatabaseReference to perform read or write operations. ```dart DatabaseReference ref = FirebaseDatabase.instance.ref(); ``` -------------------------------- ### Install Firebase Messaging plugin Source: https://github.com/firebase/flutterfire/blob/main/docs/cloud-messaging/first-message.md Command to add the firebase_messaging package to your Flutter project. ```bash flutter pub add firebase_messaging ``` -------------------------------- ### Configure Google Auth Provider for Web Source: https://github.com/firebase/flutterfire/blob/main/docs/auth/federated-auth.md Set up a GoogleAuthProvider on the web, optionally adding custom scopes and parameters like 'login_hint'. This configures the provider before initiating the sign-in flow. ```dart GoogleAuthProvider googleProvider = GoogleAuthProvider(); googleProvider.addScope('https://www.googleapis.com/auth/contacts.readonly'); googleProvider.setCustomParameters({ 'login_hint': 'user@example.com' }); ``` -------------------------------- ### Define C++ Wrapper Sources Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_storage/firebase_storage/example/windows/flutter/CMakeLists.txt Lists core, plugin, and application-specific C++ wrapper source files, prepending the wrapper root directory to each. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### List all files in a directory Source: https://github.com/firebase/flutterfire/blob/main/docs/storage/list-files.md Fetches all items and prefixes in a directory. Best suited for small directories as it buffers all results in memory. ```dart final storageRef = FirebaseStorage.instance.ref().child("files/uid"); final listResult = await storageRef.listAll(); for (var prefix in listResult.prefixes) { // The prefixes under storageRef. // You can call listAll() recursively on them. } for (var item in listResult.items) { // The items under storageRef. } ``` -------------------------------- ### Initialize Firebase Realtime Database with a Custom URL Source: https://github.com/firebase/flutterfire/blob/main/docs/database/start.md Initialize a Realtime Database instance for a specific project and database URL using `instanceFor`. ```dart final firebaseApp = Firebase.app(); final rtdb = FirebaseDatabase.instanceFor(app: firebaseApp, databaseURL: 'https://your-realtime-database-url.firebaseio.com/'); ``` -------------------------------- ### Get Multi-Factor Session Source: https://github.com/firebase/flutterfire/blob/main/docs/auth/multi-factor.md Retrieves a multi-factor session required for enrolling a new secondary factor. ```dart final multiFactorSession = await user.multiFactor.getSession(); ``` -------------------------------- ### Rebuild Flutter Application Source: https://github.com/firebase/flutterfire/blob/main/docs/app-check/default-providers.md After installing the App Check plugin, rebuild your Flutter application to incorporate the changes. ```bash flutter run ``` -------------------------------- ### Get User from UserCredential Source: https://github.com/firebase/flutterfire/blob/main/docs/auth/manage-users.md Retrieve the User object from a UserCredential object returned by authentication sign-in methods. ```dart final userCredential = await FirebaseAuth.instance.signInWithCredential(credential); final user = userCredential.user; print(user?.uid); ``` -------------------------------- ### Import Firebase Analytics in Dart Source: https://github.com/firebase/flutterfire/blob/main/docs/analytics/_get-started.md Import the `firebase_analytics` plugin into your Dart code to start using its functionalities. ```dart import 'package:firebase_analytics/firebase_analytics.dart'; ``` -------------------------------- ### Sign in a user with email and password Source: https://github.com/firebase/flutterfire/blob/main/docs/auth/password-auth.md Use this method to authenticate existing users. Note that error codes may vary based on email enumeration protection settings. ```dart try { final credential = await FirebaseAuth.instance.signInWithEmailAndPassword( email: emailAddress, password: password ); } on FirebaseAuthException catch (e) { if (e.code == 'invalid-credential') { // Email or password is incorrect. Projects with email enumeration // protection enabled (the default since September 2023) return this // code instead of 'user-not-found' or 'wrong-password'. print('Invalid email or password.'); } else if (e.code == 'user-not-found') { // Only returned when email enumeration protection is disabled. print('No user found for that email.'); } else if (e.code == 'wrong-password') { // Only returned when email enumeration protection is disabled. print('Wrong password provided for that user.'); } } ``` -------------------------------- ### Add firebase_core plugin Source: https://github.com/firebase/flutterfire/blob/main/docs/setup/_setup_main.md Install the core Firebase plugin for your Flutter project using the Flutter package manager. ```sh flutter pub add firebase_core ``` -------------------------------- ### Configure CMake Project and Build Modes Source: https://github.com/firebase/flutterfire/blob/main/tests/windows/CMakeLists.txt Sets up the project name, minimum version, and defines build configuration types for multi-config generators or standard build types. ```cmake cmake_minimum_required(VERSION 3.14) project(tests LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "tests") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Define build configuration option. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() ``` -------------------------------- ### Get ListTimestamps Query Ref Source: https://github.com/firebase/flutterfire/blob/main/packages/firebase_data_connect/firebase_data_connect/example/lib/generated/README.md Obtains the reference for a list timestamps query, allowing for subsequent execution or subscription. ```dart final ref = MoviesConnector.instance.listTimestamps().ref(); ref.execute(); ref.subscribe(...); ```