How to Add Firebase to Flutter Project From Mac Terminal?
Last Updated :
07 Mar, 2023
If you are a Flutter developer you must know that it supports multi-platform applications. It is more hectic to add firebase support for all platforms like web, android, ios, macOS, Linux, and many more to come. For every platform, there are different files and settings which consumes lots of time. Today in this article you will learn about How to add firebase to the flutter project for all platforms at 1 time from the command line. So let’s get started.
Step by Step Implementation
Step 1: Install Brew for Mac users
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Check whether the brew is installed or not
Check whether the brew is installed or not. By typing brew –version in your terminal. If it was installed you will get different commands available in the brew.
Step 3: Install npm
Refer to this link.
Step 4: Install firebase in the node
npm install -g firebase-tools
Step 5: Login with your firebase account from which you want to do hosting with the command
firebase login
Step 6: Install dart
Refer to this article: Dart SDK Installation
Step 7: Activate
dart pub global activate flutterfire_cli
Step 8: Set the path flutterfirecli by this
export PATH="$PATH":"$HOME/.pub-cache/bin"
Step 9: Go to your project folder where you want to add firebase through the same cmd only
Now check whether flutterfire is available or not for this by writing flutterfire in the command line it will show like this. If it is flutter project
If not it will show
Step 11: Now add this command
flutterfire configure
Step 12: Now select firebase project if it already creates on firebase or creates a project from the CLI only
If it is already created then you jump to the next step
If you creating a project then it will ask a question like this
Enter a project id for your new Firebase project (e.g. my-cool-project)
Step 13: Now select the platform for which you want to make the firebase project
Select and deselect the platform using the spacebar in the terminal. If you select all the platforms it will ask you a question like this answer yes to this question to add dependency in all files automatically.
The files android/build.gradle & android/app/build.gradle will be updated to apply Firebase configuration and gradle build plugins. Do you want to continue? (? The files android/build.gradle & android/app/build.gradle will be updated to apply Firebase configuration and gradle build plugins. Do you want to continue? (✔ The files android/build.gradle & android/app/build.gradle will be updated to apply Firebase configuration and gradle build plugins. Do you want to continue? · yes
Step 14: You have successfully added firebase for all platforms you selected
Step 15: Add this file in lib/main.dart
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
Now you can run the app Firebase is already added to your flutter project.
Similar Reads
How to Add Firebase to Flutter App?
Firebase is a product of Google that helps developers to build, manage, and grow their apps easily. It helps developers to build their apps faster and more securely. No programming is required on the Firebase side which makes it easy to use its features more efficiently. It provides services to Andr
3 min read
How to Add Firebase into Flutter in a New Way?
Recently Firebase give another option for adding Firebase to Flutter and It is only made for Flutter, As of now we add firebase using the android option for flutter but now we can add using the flutter option that is recently updated by Flutter. Here you can find how to add firebase as an Android in
2 min read
How to Import Existing Flutter Project in Android Studio?
In this article, we are going to see the process of importing an existing flutter Project into the Android Studio. This is going to be quite easy, we just have to take care of some steps involved in it. Before going on the main topic let's have brief info about Flutter and Android Studio as well. Fl
3 min read
Flutter - Android Studio Not Showing Project Files
There are a couple of errors that come up while making an Android app. Making the project requires less time rather than debugging the same project with errors. One such error is that when we develop a project and when we open it after a few days it does not show us the files present in the folder,
3 min read
How to Create a Zoomable Image in Flutter?
In Flutter, you can create a zoomable image using the GestureDetector and Transform widgets. The GestureDetector widget can be used to detect pinch gestures on the image, and the Transform widget can be used to apply the zoom transformation to the image. [video loading="lazy" mp4="https://media.geek
3 min read
Flutter - Read and Write Data on Firebase
Firebase helps developers to manage their mobile apps easily. It is a service provided by Google. Firebase has various functionalities available to help developers manage and grow their mobile apps. In this article, we will learn how to write and read data into/from Firebase. Follow the 3-step proce
4 min read
How to Add Route Polylines to Google Maps in Flutter?
Google Maps is used in many Android applications. We can use Polylines to represent routes for various destinations on Google Maps. So in this article, we are going to add Route Polylines to Google Maps in Flutter. Step By Step ImplementationStep 1: Create a New Project in Android StudioTo set up Fl
4 min read
Flutter Projects From Beginner to Advanced
Flutter is an open-source UI software development kit created by Google, designed for building natively compiled applications for mobile, web, and desktop from a single codebase. It uses the Dart programming language and provides a rich set of pre-designed widgets, allowing developers to create visu
4 min read
Hosting Flutter Website On Firebase For Free
Flutter is a user interface development software development kit. Flutter is an open-source project maintained by Google. It enables software developers to make beautiful natively compiled applications for IOS, Android, Web, and Desktop with a single code base. Although developing flutter applicatio
4 min read
Flutter - Pick and Open Files From Storage
Sometimes in an app, we need to pick and open a file from the phone's storage, in this article, we will achieve the same using file_picker and open_file flutter packages. 1. Create an App: Create a new flutter app by running the below command on your terminal: flutter create your_app_name Now open y
5 min read