A Step-by-Step Guide to Distributing Your Flutter App with Firebase

Nikhil Soman Sahu
3 min readDec 30, 2023

--

Guide to Distributing Your Flutter App with Firebase

Flutter, Google’s open-source UI software development toolkit, has gained immense popularity for building natively compiled applications for mobile, web, and desktop from a single codebase. When it comes to distributing your Flutter app, Firebase, another powerful platform from Google, offers a seamless solution for hosting, authentication, and various other features. In this guide, we will walk you through the process of distributing your Flutter app using Firebase.

Prerequisites:
1. A Flutter app ready for distribution.
2. A Firebase account (
https://firebase.google.com/) with a project created.

Step 1: Set up Firebase in Your Flutter Project
Firstly for distributing your Flutter app using Firebase you need to connect your Flutter project with Firebase. To do this, add the Firebase SDK to your Flutter app by following these steps:

a. Open your Flutter project in an IDE (such as Visual Studio Code or Android Studio).
b. Navigate to your project’s root directory and open the `pubspec.yaml` file.
c. Add the Firebase dependencies under `dependencies`:

dependencies:
firebase_core: ^1.10.6
firebase_auth: ^4.6.0

d. Save the file and run `flutter pub get` in your terminal to install the dependencies.

e. Import the necessary packages in your Dart code:

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';

f. Initialize Firebase in your `main.dart` file:

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}

Step 2: Configure Firebase for Distribution
Now that your Flutter project is linked to Firebase, configure Firebase for distribution:

a. Go to the Firebase Console (https://console.firebase.google.com/).
b. Select your project or create a new one.
c. In the left-hand menu, click on “Authentication” and set up the authentication method for your app (e.g., email/password, Google Sign-In).

Step 3: Prepare Your Flutter App for Distribution
Before distributing your app, you need to configure it properly. Update your Android and iOS configurations:

a. Android Configuration:
i. Obtain your `google-services.json` file from the Firebase Console.
ii. Place the file in the `android/app` directory of your Flutter project.

b. iOS Configuration:
i. Obtain your `GoogleService-Info.plist` file from the Firebase Console.
ii. Place the file in the `ios/Runner` directory of your Flutter project.

Step 4: Build Your Flutter App
Before deploying to Firebase, build your Flutter app for release. Open a terminal and run:

flutter build apk - release # For Android
flutter build ios - release # For iOS

Step 5: Deploy to Firebase Hosting
Firebase Hosting allows you to deploy and host your Flutter web app effortlessly. Follow these steps:

a. Install the Firebase CLI:

npm install -g firebase-tools

b. Authenticate with Firebase:

firebase login

c. Navigate to your Flutter project’s build directory:

cd build/web

d. Initialize Firebase Hosting:

firebase init

e. Follow the prompts to set up your hosting configuration.

f. Deploy your app:

firebase deploy

Well done! Firebase Hosting is now being used to distribute your Flutter app. Using Firebase to distribute your Flutter app is a simple process that provides scalability, dependability, and many other benefits. Using Firebase’s power for hosting and authentication, you can quickly launch your Flutter app to a worldwide user base by following the instructions in this guide.

I hope you found this tutorial to be a useful resource, with clear and concrete actions. Firebase’s integration with Flutter gives up a world of possibilities for smooth app deployment, whether you’re a seasoned developer or just starting out.

--

--

Nikhil Soman Sahu

Sr Software Developer | Spring Boot | Flutter | Dart | Java