Giter Club home page Giter Club logo

flutter-firebase-auth-template's Introduction

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.

Preview

Google Sign-in

Facebook Sign-in

Email & Password auth

Simplified widget tree

FirebaseAuth features

Supported sign-in methods

  • Anonymous
  • Email & Password
  • Email link (passwordless)
  • 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

Sign-in 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

Authentication

  • 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

Architecture

Other

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

TODO

  • 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
  • To get SHA-1 certificate do:
    • cd C:\Program Files\Java\YOUR_JDK_VERSION_HERE\bin
    • Get debug.keystore path in my case is C:\Users\YOUR_USERNAME.android\debug.keystore
    • Run "keytool -list -v -keystore C:\Users\name.android\debug.keystore -alias androiddebugkey -storepass android - keypass android" in cmd
  • On iOS, use com.codingwithflutter.firebaseAuthDemoFlutter as the bundle ID
  • then, download and copy GoogleService-Info.plist into iOS/Runner, and add it to the Runner target in Xcode

Additional setup instructions for Google and Facebook sign-in:

flutter-firebase-auth-template's People

Contributors

m1gicturtl avatar

Stargazers

 avatar  avatar

Forkers

wikitong

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.