Flutter & Firebase App Tutorial — Part 7 Firebase Sign In and Register With Email
Create a flutter authenticate app in 10 mins by using firebase as the back-end. You will learn how to enable Firebase Sign In with Email and then use Stream and Provider in Flutter to direct users to the right screen.
More Tutorials:
- Flutter & Firebase App Tutorial — Part 1 Get Started
- Flutter & Firebase App Tutorial — Part 2 App Structure
- Flutter & Firebase App Tutorial — Part 3 Firebase Sign In Anonymously
- Flutter & Firebase App Tutorial — Part 4 Custom model in Flutter App
- Flutter & Firebase App Tutorial — Part 5 Stream & Provider in Flutter
- Flutter & Firebase App Tutorial — Part 6 Firebase Sign Out
- Flutter & Firebase App Tutorial — Part 7 Firebase Sign In and Register With Email
- Flutter & Firebase App Tutorial — Part 8 toggle between forms and form validation
- Flutter & Firebase App Tutorial — Part 9 loading Spinkit and theme & layout
- Flutter Animation Tutorial
- Using SQLite In Flutter
Table of Contents
- Enable Firebase
signInWithEmailAndPassword()
- Create Sign-In Form in Flutter
- Create Sign Up Form in Flutter
Step 1️⃣: Enable Firebase signInWithEmailAndPassword()
in the service auth_service.dart
file
//sing in with email & password
Future signIn(String email, String password) async{
try{
return await _auth.signInWithEmailAndPassword(email: email, password: password);
}
catch(e){
print(e.toString());
return null;
}
}
Step2️⃣: Create Sign In Form in Flutter
✅ Create a TextFormField
for the email. Inside the TextFormField
, we specify what is going to happen when this form field changes by adding a onChanged
property.
The onChanged
property is equal to a function that takes in the value and then inside the onChanged
function, we use setState
to let the email
property be equal to the value.
✅ Create a TextFormField
for the password.
Inside the TextFormField
, we add a obscureText
property so the password will not be shown while typing.
We take the password state and set it to whatever the value currently is inside the TextFormField.
SizedBox(height: 20.0),
TextFormField(
validator: (value) => value!.length < 6 ? 'Enter a password 6+ charts long': null,
obscureText: true,
onChanged: (value){
setState(() => password = value);
},
),
✅ A Sign In
button that integrates the icon button with the Firebase signInWithEmailAndPassword()
in the service.
Next, we will do the same for the registration form in the Sign_up.dart
file.
More Tutorials:
- Flutter & Firebase App Tutorial — Part 1 Get Started
- Flutter & Firebase App Tutorial — Part 2 App Structure
- Flutter & Firebase App Tutorial — Part 3 Firebase Sign In Anonymously
- Flutter & Firebase App Tutorial — Part 4 Custom model in Flutter App
- Flutter & Firebase App Tutorial — Part 5 Stream & Provider in Flutter
- Flutter & Firebase App Tutorial — Part 6 Firebase Sign Out
- Flutter & Firebase App Tutorial — Part 7 Firebase Sign In and Register With Email
- Flutter & Firebase App Tutorial — Part 8 toggle between forms and form validation
- Flutter & Firebase App Tutorial — Part 9 loading Spinkit and theme & layout
- Flutter Animation Tutorial
- Using SQLite In Flutter
Seeing my followers grow will encourage me to write more articles. If you have any questions or anything to be improved please write a comment in the comments section.
I am a Flutter lover, and I talk about flutter, mobile development, and artificial intelligence.
👉 The source code is updated in Github