A sample template for Flutter + Firebase mobile apps

Overview

Flutter Project

Out-of-the-box features/tools

  • Router integration and simple page setup boilerplate
  • Login/Register/Profile pages with Firebase Authentication
  • Check for app updates to force update (using Firebase Remote Config)
  • Logger that make logging easier and sends error logs to Firebase Crashlytics
  • Firestore configuration and model/services structuring with helper methods
  • FCM notifications with Firebase Messaging and Local Notifications integration that enables foreground and background notifications
  • Sync FCM token with Firestore for the logged in users

Running Project

It is recommended to use fvm to run the project. You can install fvm by following the instructions here. If you have fvm installed, you can run the following command,

fvm use
fvm flutter run

Configuration

Enabled Services

  1. Authentication https://firebase.flutter.dev/docs/auth/start
  2. Firestore https://firebase.flutter.dev/docs/firestore/usage
  3. Crashlytics https://firebase.flutter.dev/docs/crashlytics/usage
  4. Cloud Messaging https://firebase.flutter.dev/docs/messaging/usage
  5. Remote Config https://firebase.flutter.dev/docs/remote-config/overview
  6. Analytics https://firebase.flutter.dev/docs/analytics/overview

Project setup

  1. Create a firebase project. No need to add any apps yet.
  2. Install flutterfire. (Tested with version 0.2.4)
  3. Use flutterfire configure to configure the project and add android/iOS apps. (Run this again if you change the application id/add new services)
  4. Run configure.py script using python configure.py. You may need to install python. Delete the configure.py file after running the script. If something goes wrong while running the script, reset the project using git reset --hard and try again.
  5. Run fvm flutter pub get to install all the dependencies.
  6. Run the app.
  7. Crash app using top right button and use dashboard to make sure crashlytics integration works.
  8. Send a self notification to make sure local notifications integration works.
  9. Send a test notification via the dashboard (The FCM registration token will be logged in to the console) and check if it arrives (Both when app is in foreground/background). Tapping it should show a success message.
  10. Set and publish minimumAppVersion in Remote Config to 2.0.0 (higher than current), now when you open the app, there should be a message saying that you need to update the app.

Note: To rename the intellij project properly, use intellij refactoring.

Firebase Local Setup/Use Emulators

  1. Run firebase init in firebase project directory and enable services and emulators.
  2. You can deploy firebase project via firebase deploy. Use firebase deploy --only firestore to deploy firestore rules only.
  3. Start emulators by firebase emulators:start.
  4. In the app, set DebugConstants.enableEmulators to true.
  5. Run the app in a android emulator in the same device as firebase emulators.
  6. Now app should connect to firebase emulator.

Design Choices

State Management

The project uses Riverpod to manage the state of the application. The relevant provider code is in lib/providers directory. Additionally, Flutter Hooks are used for manage life cycle of the widgets.

Models

The json models are in lib/models directory. These will be generated using build_runner. The models should not have any dependencies on other packages or any associated logic.

Code generator can be run by following command,

fvm flutter pub run build_runner build --delete-conflicting-outputs

Services

The services are in lib/services directory. Each firebase service will extend FirebaseService class. All query/write/delete methods will be implemented in the associated service class. Each service will also accompany a abstract class (which defines the interface) and a implementation class.

Providers

The providers are in lib/providers directory.

Routing

This project uses Auto Route to handle routing. The relevant code is in lib/router directory. Since this routing package is using code generation, you will have to run build_runner everytime routing code is changed.

Common Widgets

All common widgets live inside lib/widgets directory.

Flutterfire UI is integrated. This includes several auth and firestore widgets. See Flutterfire UI Widget Catalogue for more details.

Pages

All pages live inside lib/pages directory. Each page should be inside directories that represent their feature/use-case.

Logging

The project uses Logger to log the events. Logging can be done simply as Log.d("message") (for debug) or Log.i("message") (for info) or Log.w("message") (for warning) or Log.e("message") (for error). You may also pass an Exception and a StackTrace to log the error as Log.e("message", e, stackTrace).

Note: If the logs are crowded with unnecessary logs, apply following filter (VS Code): I/flutter

Future Work

You might also like...

Projeto do curso Criação de Apps Android e iOS com Flutter 2021-Crie 14 Apps. Professor: Daniel Ciolfi

agenda_contatos Projeto do curso de Flutter Getting Started This project is a starting point for a Flutter application. A few resources to get you sta

Nov 27, 2021

Projeto do curso Criação de Apps Android e iOS com Flutter 2021-Crie 14 Apps. Professor: Daniel Ciolfi

busca_gifs A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Nov 25, 2021

This is an apps that implements fundamental features of Flutter (Android Apps Only)

rpl_apps_flutter A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Dec 28, 2021

Github-apps-flutter - Github Apps Build Using bloc 8.0 and Github API

Github-apps-flutter - Github Apps Build Using bloc 8.0 and Github API

Github_apps Inspiration This app is made to build using bloc 8.0 and github API.

Apr 14, 2022

Let's setup Firebase​​ for our Flutter​​ app on Android​, iOS​ and Flutter Web. Setup Firebase to use Firebase products.

Let's setup Firebase​​ for our Flutter​​ app on Android​, iOS​ and Flutter Web.  Setup Firebase to use Firebase products.

Flutter Tutorial - Firebase Setup For Flutter Web Let's setup Firebase for our Flutter app on Android, iOS and Flutter Web. Setup Firebase to use Fire

Apr 27, 2022

CARP Mobile Sensing for Flutter, including mobile sensing framework, data backend support, and the CARP mobile sensing app.

CARP Mobile Sensing for Flutter, including mobile sensing framework, data backend support, and the CARP mobile sensing app.

This repo hold the source code for the CACHET Research Platform (CARP) Mobile Sensing (CAMS) Flutter software. It contains the source code for CACHET

Dec 16, 2022

Flutter-Onboarding-UI-Concept - A Flutter conceptual design for on boarding screens for mobile apps

Flutter-Onboarding-UI-Concept - A Flutter conceptual design for on boarding screens for mobile apps

flutter_onboarding_ui_concept A conceptual design for on boarding screens for mobile apps. This app provides you with all the information you need to

Dec 25, 2022

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing

Jan 8, 2023

A responsive scaffold widget that adjusts to your device size, for your flutter mobile and web apps.

A responsive scaffold widget that adjusts to your device size, for your flutter mobile and web apps.

scaffold_responsive A responsive scaffold widget that adjusts to your device size, for your flutter mobile and web apps. Check out the Live demo here

Sep 27, 2022
Owner
iXD Labs
iXD Labs is a tech startup that focuses on using cutting-edge technologies to innovate products and services to serve our customers.
iXD Labs
meg4cyberc4t 11 Oct 24, 2022
Repository with sample Flutter Apps

If you like it the content please show me your support ❤️ with a star ⭐ Description This project contains some sample applications created with Flutte

Moises Cervantes 34 Jul 31, 2022
This is a template repository for starting flutter apps with some pre build codes.

flutter_mobile_template A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you

Mazharul Sabbir 5 Nov 16, 2022
This is a sample Flutter Authentication using Firebase

Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing

null 1 May 11, 2022
Now UI Flutter is a fully coded app template built for Flutter which will allow you to create powerful and beautiful e-commerce mobile applications

Now UI Flutter is a fully coded app template built for Flutter which will allow you to create powerful and beautiful e-commerce mobile applications. We have redesigned all the usual components to make it look like our Now UI Design, minimalistic and easy to use.

null 12 Oct 9, 2022
Project-x2 - A Flutter E-Commerce starter template that bootstraps development of your mobile application

Flutter E-Commerce UI KIT A powerful Flutter E-Commerce starter template that bo

null 1 Apr 7, 2022
A sample app of using the image_picker + path_provider and permission_handler package to request permission and store photos on mobile

image_picker_example A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you sta

iang12 4 Apr 19, 2022
🚗 Apple CarPlay for Flutter Apps. Aims to make it safe to use apps made with Flutter in the car by integrating with CarPlay.

CarPlay with Flutter ?? Flutter Apps now on Apple CarPlay! flutter_carplay aims to make it safe to use iPhone apps made with Flutter in the car by int

Oğuzhan Atalay 156 Dec 26, 2022
[Example APPS] Basic Flutter apps, for flutter devs.

Show some ❤️ and star the repo to support the project This repository containing links of all the example apps demonstrating features/functionality/in

Pawan Kumar 17.9k Jan 2, 2023
Flutter-Apps-Collection: a collection of apps made in flutter for learning purpose

Flutter-Apps-Collection This is a repository of a collection of apps made in flutter for learning purpose Some Screenshots . . . Apps build in Flutter

Himanshu Singh 96 May 27, 2022