Firebase setup using Flutterfire cli has made the integration much easier than earlier minimizing the chance of gradle error in the setup process.
The installation process might skip asking for application id if you've created flutter project by
flutter create projectname --org com.projectname
Below are the steps to follow while setting up flutterfireHere we are going to install using npm.
1. Under prepare your workspace section
-
Install Node.js
use
npm --version
to check installed version once installed or if it's already installed. Install the Firebase CLI via npm by running the following command:
npm install -g firebase-tools
This will add firebase CLI to your system. To confirm the installation use
firebase --version
.If there shows an error of
firebase command not found
or anything related to that. It is recommended to restart your terminal or command prompt
- Login to firebase
firebase login
This will navigate to browser choosing the email you want to link your local project with remote project.
2. Under Install and run the FlutterFire CLI
- Check for the firebase projects with the following command:
firebase projects:list
This will list all the firebase project made with your gmail account.
- Now, activate the flutterfire cli
dart pub global activate flutterfire_cli
- In windows if you're installing the flutterfire cli for first time then you'll get a warning asking to add the path to your environment variables.
- Just copy the path and add to environment variables for windows
- For macos copy the export command and paste it to terminal.
- Then, at the root of your Flutter project directory, run this command:
flutterfire configure
This will show all the available projects and let you to choose the firebase project you want to integrate.
use arrow keys to navigate and spacebar to select the project
choose the platform you want to build the project for.
** After registering the platform for which you're building the project, it will ask for the android application id.
- GO TO
android/app/build.gradle
and search for android->namespace which might look likecom.example.projectname
- copy and paste it to your terminal providing the android application id.
- This will add
firebase_options.dart
file tolib
folder of your Flutter project.
3. Install firebase_core dependency.
flutter pub add firebase_core
This will solve the error showing the missing of package.
Now you're good to go! You've linked your flutter project with firebase.
Top comments (0)