Email/Password Sign-In allows a user to authenticate using an email address and password.
Email sign-in demo
Before getting started with this section, ensure you have:
- Completed Initial setup required for authentication. (Please note: Skip if you have already enabled authentication and created a user collection while creating your project with Firebase Setup.)
Adding Email Sign-In comprises of the following steps:
To enable Email and Password authentication in the Firebase:
- 2.Click on the Get started button.
- 3.Select the Sign-in method tab.
- 4.Click on the Email/Password (Under the Native Providers section).
- 5.Inside the Sign-in providers section, find the Email/Password switch and enable it.
- 6.Click on the Save button.
Enabling email authentication in Firebase
FlutterFlow provides a collection of account creation templates. You can either choose from the templates or create from scratch.
You can continue reading here to see how to create authentication pages from scratch or click here to move on to the next section.
Here's an example of how you can create a page with TabBar for sign-in and sign-up:
- 1.Click on the Select Page or Component from the Navigation Menu (left side of your screen).
- 2.Click on + Create New, Give it a name.
- 3.Click on the + Create New button under the Blank Page template.
- 4.Click on the Widget Tree from the Navigation Menu.
- 5.Add the TabBar widget from the Layout Elements tab (in the Widget Panel) or add it directly from the widget tree.
- 6.Select any Tab from the widget tree or from the canvas area and hit the Delete button (or right-click and select cut) to remove one of the tabs.
- 7.Select the First Tab and change the Tab Label to Sign In.
- 8.Select the Second Tab and change the Tab Label to Sign Up.
- 9.Set the TabBar Padding to 20 for all sides.
Adding TabBar for sign-in and sign-up form
To create a Sign In form inside the Tab:
- 1.Select the first TabBar Page from the widget tree or from the canvas area.
- 2.Inside the TabBar Page, replace the Text widget with the Column widget.
- 3.Add the TextField widget inside the Column and change its Hint Text to Email. Change the widget's name to Email by clicking the edit icon (top right corner).
- 4.Add another TextField widget below and change its Hint Text to Password.
- 5.Find and checkmark the Password Field property (under Textfield Properties).
- 6.Change the name to Password by clicking the edit icon.
- 7.Finally, add the Button widget from the Base Elements tab and change the Text to Login. Change the name to Button-Login by clicking the edit icon.
Creating a sign-In form
To create a Signup form inside the Tab:
- 1.Select the TabBar widget from the widget tree or from the canvas area.
- 2.Move to Property Editor and find the Active Tab dropdown and change it to Sign up.
- 3.Inside the TabBar Page, replace the Text widget with the Column widget.
- 4.Add the TextField widget inside the Column and change its Hint Text to Name. Change the name to Name by clicking the edit icon (top right corner).
- 5.Add one more TextField widget below and change its Hint Text to Age. Change the name to Age by clicking the edit icon.
- 6.Add the TextField widget below and change its Hint Text to EmailSignup Change the name to EmailSignup by clicking the edit.
- 7.Add another TextField widget below and change its Hint Text to PasswordSignup. Find and checkmark the Password Field property. Change the name to PasswordSignup by clicking the edit icon.
- 8.Finally, add the Button widget from the Base Elements tab and change the Text to Signup. Change the name to Button-Signup by clicking the edit icon.
Creating a sign-up form
To log out, you need to add a logout action. This could be a button on your settings page, an icon button on your AppBar, or another location.
You can test the Email/Password authentication on a device/emulator as well as in Run Mode. To use Run Mode, make sure you have completed the Firebase setup.
To test authentication in Run Mode:
- 1.Click on the Run button (top right corner of your screen)
- 2.Open the signup form and enter the credentials for creating a user.
- 3.Click on the Logout button.
- 4.Switch to the sign-in form and enter the credentials for the previously created user.
- 5.Click on the Logout button.
To verify the creation of a new user in Firebase:
- 1.Open the Firebase console, and click on Authentication.
- 2.Select the Users tab.
- 3.Find the email for the newly created user in the identifier column.
- 4.Now click on the Firestore Database in the left side menu.
- 5.Select the users collection and find the entry for the new user.
Verify user creation in Firebase