Add Firebase to Flutter app with FlutterFire CLI

Samed Demir
LCW Digital
Published in
2 min readMar 19, 2023

Hello,

The subject of my article is to quickly integrate into our project with a single click on 3 different platforms (iOS/Android/Web).

First, let’s start with the FlutterFire CLI installation.

dart pub global activate flutterfire_cli

Install a new flutter application and provide my tests on it.

flutter create firebase_test_app

We will write the Main() method including Firebase commands.

import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
}

We will do the normal steps to create new app via Firebase

Create Project
Step-1

After completing these steps, we will make some adjustments on the console and add our project.

In the project directory, type flutterfire configure on the terminal. The screen shown in the picture will appear by entering the account you have opened the Firebase project.

Step 1
Step 2
Step 3

After all stages, we provide control over Firebase.

 flutter pub add firebase_core
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'firebase_options.dart'; <--

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized(); <--
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); <--
runApp(const MyApp());
}

We have completed all the configuration steps and now we should have our app running smoothly :)

Happy Coding!

--

--