Getting Text Values from Form Fields

We are going to be using a Form widget and a GlobalKey , additional information on these concepts can be found in the flutter cookbook section Building a form with validation.

Add the formKey in the LoginPage widget:

Then add two new fields to hold the email address and password values we will need to send to Firebase for authentication:

Next, add a property onSaved to the TextFormFields we have for email and password. When the save method is called on the form, all of the widgets onSaved methods will be called to update the local variables.

Wrap the Column widget with a new Form widget, the code should look similar to this:

Now that the fields are set and the TextFormField are updated, we can use the _formKey to not only validate the fields provided but also retrieve the values locally by calling the save method.