This project is an example of Firebase authentication in a Flutter. This project shows how to implement a full authentication flow in Flutter using Email/Password and Google authentication.
It aims to be a reference implementation. Think of it as "authentication done right".
This project shows how to:
- Sign up with an email and password
- Sign in with that email and password
- Verify email
- Reset password
- Sign up with Google authentication
- Sign in with Google authentication
- 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.
- After getting a project from GitHub run
flutter pub upgrade
to get the latest dependencies - Next run
flutterfire configure
to createfirebase
project and associate your Flutter app with Firebase project. This will also addgoogle-services.json
andfirebase-options.dart
files to your project. If you haven't configured Firebase before follow these instructions to configure Firebase SDK. Note that there are a lot of problems with stand alone installation on Windows, you are better off usingnpm
approach even though it is a little more diffcult to configure - For Google authentication you have to add your SHA certificate fingerprint to your project in Firebase console. In dev, use below command to get your dev certificate fingerprints (SHA1 and SHA256) and paste them into Firebase console undr project settings:
keytool -list -v -keystore "C:\Users\YourUserName\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
- In
Firebase Console
add Authentication to your project ad enable email/password authentication. Also, add another provider and configure Google authentication method. Runflutterfire configure
again (you have to do this after making changes in the console) - You should now be able to run the app
- ✔ Android
- ✔ web
- ❌ windows
Sign-in
Sign-Up
Forgot-Password
Home
- ✔ Null safety
- ✔ Firebase
- ✔ firebase_core
- ✔ firebase_auth1
- ✔ provider
- ✔ Email & Password Sign In
- ✔ Email & Password Sign Up
- ✔ Reset Password
- ✔ Verify Email
- ✔ Google authenticaton
- ✔ Select between email/password and Google authnticaton
- ✔ Form to enter email and password for signing-in the user.
- ✔ Button to toggle sign-up view.
- ✔ Button to navigate to forgot password page.
- ✔ Form to enter a name, email, and password for signing up the user.
- ✔ Button to toggle sign-in view.
- ✔ Form to enter email for resetting the password.
- ✔ Button to navigate to the sign-in page.
- Mobile number authentication
- signin/signup via facebook
- signin/signup using twitter
- signin/signup using github