Add Firebase to Flutter using Cli
The FlutterFire CLI is a handy tool that offers a set of commands designed to simplify and streamline the installation process of FlutterFire across all supported platforms. It provides an easy and efficient way to set up FlutterFire, ensuring smooth integration for developers working on multiple devices and operating systems.
Watch this article as video for explaining in details:
https://youtu.be/wImplq2qDZs
https://youtu.be/wImplq2qDZs
Installation:
The FlutterFire CLI relies on the Firebase CLI to function properly. If you haven't installed the Firebase CLI yet, you'll need to do so before using FlutterFire. To get started, ensure that Node.js is installed on your computer. Once you have Node.js, you can install the Firebase CLI through npm by running the following command:
npm install -g firebase-tools
Next, you'll need to install the FlutterFire CLI. You can do this by running the following command:
dart pub global activate flutterfire_cli
now flutterfire is globally available inside your system
Usage
If you initialize your Firebase app using Dart, you might see warning logs from the native iOS Firebase SDK, stating that no Firebase app has been configured (i.e., missingGoogleService-Info.plist
). You can safely disregard these warnings as they appear when the Firebase app is initialized directly from Dart.
FlutterFire can be set up from Dart on any platform using Firebase.initializeApp
, though the setup options may differ depending on the platform. The FlutterFire CLI makes this process easier by creating a configuration file, typically named firebase_options.dart
, which you can use when initializing Firebase in your app. It gathers details from your Firebase project and the specific applications you've chosen to generate the necessary configurations for each platform.
Our website also features a YouTube channel dedicated to coding and tech-related content. Additionally, we specialise in mobile application development. If you need assistance or have any inquiries, feel free to reach out—we’re just a message away!
Visit youtube 👉 CODEMICROS
At the root of your application, execute the following command to configure it:
flutterfire configure
The configuration command will walk you through several steps:
- Choose a Firebase project (from the
.firebaserc
file or the Firebase Console). - Specify the platforms (e.g., Android, iOS, macOS, web) you want to configure.
- Select which Firebase apps for the chosen platforms will be used to extract the configuration.
- By default, the CLI tries to auto-match Firebase apps with your project setup.
- It will generate a
firebase_options.dart
file in your project.
Now you can have to setup the firebase in your code and ready to explore it.
~~~ Thank You ~~~