Firebase Flutter Quickstarts

repository·main·Indexed 41 days ago

https://github.com/firebase/quickstart-flutter

A collection of standalone Flutter projects providing quickstart guides for implementing Firebase services. Includes examples for AdMob, Google Analytics, Firebase Auth (Email/Password), Cloud Functions, Crashlytics, Firebase Data Connect, Dynamic Links, and Cloud Firestore using official Firebase Flutter plugins.

Tokens
17.3K
Snippets
65
Records
95
Agent score
52%

What's inside Firebase Flutter Quickstarts

  1. Explore Firebase Flutter Quickstart Samples

    main

    This repository contains a collection of quickstart samples designed to demonstrate the capabilities of various Firebase Flutter plugins. Each sample is an independent project that can be run on a mobile device, a virtual device (emulator/simulator), or a web browser.

    Available samples include:

    • Firestore: Demonstrates Cloud Firestore integration.
    • Authentication: Demonstrates Firebase Authentication integration.
    • Crashlytics: Demonstrates Firebase Crashlytics integration.
  2. Display Banner and Interstitial ads with AdMob

    main

    The AdMob quickstart demonstrates two primary ad types:

    1. Banner Ads: Displayed using AdRequest and AdView.
    2. Interstitial Ads: Full-screen ads displayed using the InterstitialAd class.

    By default, the sample application displays a test banner ad and provides a button to trigger a test interstitial ad.

  3. Run Firebase Cloud Functions locally using Emulators

    main

    To test functions locally without deploying to production, use the Firebase Emulator Suite. In the cloud_functions directory, you can build the function code and start the emulators with a single command. This quickstart uses a V1 function located in the firebase_functions folder.

    npm run build && firebase emulators:start
  4. Customize the iOS launch screen assets

    main

    To change the image displayed during the app's launch on iOS, you can either replace the image files directly in the cloud_functions/ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory or use Xcode for a more visual approach.

    Using Xcode:

    1. Open the iOS workspace from your Flutter project root using: open ios/Runner.xcworkspace.
    2. In the Xcode Project Navigator, navigate to Runner/Assets.xcassets.
    3. Drag and drop your desired images into the asset catalog to replace the existing launch images.
    open ios/Runner.xcworkspace
  5. Get started with Firestore in Flutter

    main

    To use Firestore in this project, follow these setup steps:

    1. Flutter Setup: Follow the official Firebase Flutter setup guide.
    2. Enable Authentication: In the Firebase Console, go to the Authentication tab > Sign-in Method and enable the 'Anonymous sign in provider'.
    3. Create Database: Create a Firestore database instance in the Firebase Console.
    4. Environment: Ensure your Flutter development environment is configured for Firestore.
  6. Configure AdMob App ID for iOS

    main

    To use AdMob in your Flutter project on iOS, you must provide your AdMob app ID in the Info.plist file. Locate the ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy placeholder and replace it with your actual AdMob app ID.

    File path: ios/Runner/Info.plist

    <!-- In ios/Runner/Info.plist -->
    <key>GADApplicationIdentifier</key>
    <string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string>
  7. Measure custom activities with Firebase Performance traces

    main

    You can measure the performance of specific activities in your Flutter application by using custom traces. To implement a custom trace:

    1. Create a new trace using FirebasePerformance.instance.newTrace('yourTraceName').
    2. Start the trace.
    3. Perform the activity you want to measure.
    4. Stop the trace by awaiting the stop method.

    Once recorded, you can view these traces in the Firebase console under the 'Custom Traces' tab.

    var trace = FirebasePerformance.instance.newTrace('myTag');
    await trace.start();
    // ... perform activity ...
    await trace.stop();