Real-time shared expense tracker app using Flutter and Firebase: Part 2— Creating a Firebase project using Firebase CLI

Siddhesh Inamdar
2 min readDec 15, 2023

--

In the previous article — Part 1, I mentioned the high-level app design. In this section, I’ll mention the steps to start this specific Firebase project using the Command Line Interface (CLI) on a Windows machine. The general steps are taken from the Firebase documentation. The steps for starting this project are:

  1. Install Firebase CLI

Firebase CLI uses Node.js. We must install npm (the Node Package Manager) to install the CLI and enable the globally available Firebase command. sometimes there will be issues accessing the Firebase command globally, so we should usually add the npm installation path to system variables. Then open Windows Powershell to try these commands for 1. Getting global execution permissions, 2. installing Firebase tools.

> Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
> npm install -g firebase-tools

2. Logging in Firebase and creating the project:

After the login command, follow the prompted steps to get logged in. This is only one time, later on, firebase will log in to the user automatically. After that, we can see already existing firebase projects.

> firebase login
> firebase projects:list

3. Initializing a project and adding Firebase to the Flutter app:

We need to configure the Firebase project and add some Firebase libraries to the Flutter app. Including the Fluterfire CLI, and Firebase core. Then we can configure some settings for Firebase. And then run the project.

project_dir> dart pub global activate flutterfire_cli
project_dir> flutter pub add firebase_core
project_dir> flutterfire configure

Meanwhile in the flutter app, we can add the Firebase Initialize command in the main functions.

await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);

After we start the project, we need to initialize firebase in the project with dependencies that we will use. We can then select Functions and Realtime database options to continue in the project. There will be a few more CLI prompts to create some .json files. after that the firebase part of client side is complete. If the program runs into any errors, adding ‘ — debug’ will print the entire log.

project_dir> firebase init

After this, the Firebase CLI is initialized, we’ll come back here again once we have to deploy Functions on cloud. Now, we can configure the flutter app in the next article — Part 3.

--

--

Siddhesh Inamdar

Techie chemical engineer. ML professional @ ExxonMobil BTC