Skip to content
Reference Authentication Flow with Flutter & Firebase
Dart Ruby Other
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
android Sign-in with email link (#28) Aug 5, 2019
assets Add SignInPage with Google, Facebook, email & password, anonymous auth Apr 4, 2019
docs Sign-in with email link (#28) Aug 5, 2019
ios Update all dependencies. Bump iOS deployment target to 9.0 (#43) Oct 17, 2019
lib Update all dependencies. Bump iOS deployment target to 9.0 (#43) Oct 17, 2019
media Rename AuthWidget -> AuthWidgetBuilder, LandingPage -> AuthWidget Oct 8, 2019
test Only update loading state ValueNotifier when authentication calls fai… Oct 11, 2019
test_driver Add sign-in/sign-out integration tests with Flutter driver (#37) Sep 29, 2019
.gitignore Show camera image icon when avatar is not loaded. Version 0.0.8+2 Sep 19, 2019
.metadata Initial commit Apr 4, 2019 Update all dependencies. Bump iOS deployment target to 9.0 (#43) Oct 17, 2019 Update links to Firebase docs. Update License Oct 8, 2019 Update links to Firebase docs. Update License Oct 8, 2019
analysis_options.yaml Sign-in with email link (#28) Aug 5, 2019
sylph.yaml Add sylph configuration file for testing on AWS device farm Oct 2, 2019

Reference Authentication Flow with Flutter & Firebase

Codemagic build status

YouTube video walk-throughs here:

Flutter & Firebase: Reference Authentication Flow - Intro

Flutter & Firebase: Authentication Service with Provider & ValueNotifier

This project shows how to implement a full authentication flow in Flutter, using various Firebase sign-in methods.

It aims to be a reference implementation. Think of it as "authentication done right".

Project goals

This project shows how to:

  • use the various Firebase sign-in methods
  • build a robust authentication flow
  • use appropriate state management techniques to separate UI, logic and Firebase authentication code
  • handle errors and present user-friendly error messages
  • write production-ready code following best practices

Feel free to use this in your own projects. 😉

NOTE: This project will be kept up to date with the latest packages and Flutter version.


Google Sign-in

Facebook Sign-in

Email & Password auth

Simplified widget tree

FirebaseAuth features

Supported sign-in methods

  • Anonymous
  • Email & Password
  • Email link (passwordless) (see documentation)
  • Facebook
  • GitHub
  • Google
  • Phone
  • Twitter

Link account with third-party providers

  • Email & Password
  • Facebook
  • GitHub
  • Google
  • Phone
  • Twitter

Other authentication features

  • Email verification (for email & password sign-in)
  • Password reset
  • Sign-in with custom token

Application features

Page

  • Navigation to email and password sign-in
  • Google sign-in
  • Facebook sign-in
  • Anonymous sign-in

Email & password page

  • Custom submit button with loading state
  • Disable all input widgets while authentication is in progress
  • Email regex validation
  • Error hints
  • Focus order (email -> password -> submit by pressing "next" on keyboard)
  • Password of at least 8 characters
  • Show/hide password
  • Password reset flow

Email link page

  • Email input field, backed by secure storage


  • Abstract AuthService class, modeled after the firebase_auth API
  • FirebaseAuthService implementation
  • MockAuthService for testing
  • Firebase project configuration for iOS & Android
  • Toggle FirebaseAuthService and MockAuthService at runtime via developer menu



  • Platform-aware alert dialogs for confirmation/error messages
  • Fully compliant with the official Flutter analysis_options.yaml rules


  • Internationalization
  • Full test coverage
  • Improve documentation

Running the project with Firebase

To use this project with Firebase authentication, some configuration steps are required.

  • Create a new project with the Firebase console.
  • Add iOS and Android apps in the Firebase project settings.
  • On Android, use com.codingwithflutter.firebase_auth_demo_flutter as the package name (a SHA-1 certificate fingerprint is also needed for Google sign-in).
  • then, download and copy google-services.json into android/app.
  • On iOS, use com.codingwithflutter.firebaseAuthDemo as the bundle ID.
  • then, download and copy GoogleService-Info.plist into iOS/Runner, and add it to the Runner target in Xcode.

See this document for full instructions:

Additional setup instructions for Google and Facebook sign-in:

Additional References

A lot of the techniques used in this project are explained in great detail, and implemented step-by-step in my Flutter & Firebase Udemy course.

This is available for early access at this link (discount code included):

License: MIT

You can’t perform that action at this time.