Flutter Auth Flow | Firebase_auth mail auth

as we all want some good looking login view in our app, but problem comes your apps needs logging in every-time you open your app 😿…

but no fear, when we are here 😎.

first we need to setup firebase in our app and then add two plugin in our app..

firebase_core: ^1.14.0
firebase_auth: ^3.3.12

but remeber to use latest versions, now let’s get into CODE.

Main function of app

first we initalize firebase though options are to be used only if you use flutterfire-cli to initalize firebase

then follows our MyApp class:

MyApp stateless widget for flutter

we return a new wrapper called AuthWrapper which we will create now:

now we create a auth wrapper to return home screen acording to data in user returned by firebase.

now our login screen:

first we create a new statefull widget and initaze controllers for screen in it:

we return this widget from it, its simple two text fields and a button to sign in with email and password.

now, our full code for this screen:

now lets move in to home screen:

when we are on home screen we just show a button to signout from account..

now i create a new user in firebase console. and try it…

Written by:

Nipun Attri

see you soon.. 👋

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store