CLI
Notice
This page is archived and might not reflect the latest version of the FlutterFire plugins. You can find the latest information on firebase.google.com:
The FlutterFire CLI is a useful tool which provides commands to help ease the installation process of FlutterFire across all supported platforms.
#
InstallationThe FlutterFire CLI depends on the underlying Firebase CLI. If you haven't already done so, make sure you have the Firebase CLI installed on your machine. If not, make sure you have node.js on your machine and Install the Firebase CLI via npm by running the following command:
Learn more about the Firebase CLI in the documentation.
Next, install the FlutterFire CLI by running the following command:
Once installed, the flutterfire
command will be globally available.
#
Usagenote
If you initialize your Firebase app from Dart, you may receive warning logs from the native iOS Firebase SDK indicating no Firebase app has been configured (i.e. GoogleService-Info.plist
). You can safely ignore these logs if
you're initializing your Firebase app from Dart.
FlutterFire can be initialized from Dart on all platforms using Firebase.initializeApp
, however
the options for different platforms can vary. The FlutterFire CLI can help, by generating a file
(by default called firebase_options.dart
) which can be used when calling the initialization method.
The FlutterFire CLI extracts information from your Firebase project and selected project applications to generate all the configuration for a specific platform.
In the root of your application, run the configure
command:
The configuration command will guide you through a number of processes:
- Selecting a Firebase project (based on the
.firebaserc
file or from the Firebase Console). - Prompt what platforms (e.g. Android, iOS, macOS & web) you would like configuration for.
- Identify which Firebase applications for the chosen platforms should be used to extract configuration for. By default, the CLI will attempt to automatically match Firebase apps based on your current project configuration.
- Generate a
firebase_options.dart
file in your project.
Once complete, you can now import the generated file and provide it to the initializeApp
method:
Then, provide the current platform options via the currentPlatform
getter from the DefaultFirebaseOptions
class:
note
If you add support for a new platform in your Flutter app (e.g. adding Android when your app previously did not support Android), or if you introduce new Firebase services into your app (e.g. adding firebase_database
) then you should reconfigure Firebase for your application again via the CLI (flutterfire configure
).
#
Commands#
ConfigureGenerates a firebase_options.dart
file which can be provided to the options
parameter when
Initializing Firebase.
The command supports the following option arguments:
Argument | Alias | Description |
---|---|---|
--project | -p | Sets the Firebase Project ID to use. By default, the CLI will attempt to fetch the project defined in the .firebaserc file, or prompt you to select the project from the Firebase Console. |
--account | -e | Sets the email address which should be used to authenticate with Firebase against. By default, this will use the primary account defined on the Firebase CLI. |
--out | -o | Specifies the path & file name for the generated file. Defaults to "lib/firebase_options.dart". |
--ios-bundle-id | -i | The bundle identifier of your iOS app, e.g. "com.example.app". If no identifier is provided, an attempt will be made to automatically detect it from your "ios" folder (if it exists). |
--macos-bundle-id | -m | The bundle identifier of your macOS app, e.g. "com.example.app". If no identifier is provided, an attempt will be made to automatically detect it from your "macos" folder (if it exists). |
--android-package-name | -a | The package name of your Android app, e.g. "com.example.app". If no package name is provided, an attempt will be made to automatically detect it from your "android" folder (if it exists). |
--[no-]apply-gradle-plugin | -g | Whether to add the Firebase Gradle plugin to your Android app's build.gradle files and create the google-services.json file in your ./android/app folder. (defaults to on) |
#
VersionTo view the current version of the FlutterFire CLI, run:
#
Updating the CLIIf your CLI version is no longer the latest published version then you will be prompted to automatically update your CLI to the latest version when you run flutterfire --version
. Alternatively
you can manually trigger an update via the following command:
#
Reporting an issueIf you have encountered any issues with the CLI, please report them here.