Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In the last section, we created this form key instance variable, we assigned it an instance of a global
key that has kind of conformed to expect to reference a form state instance, and then we pass that
key off to our form that we created right here.
So now our form is going to reference the form state instance that is created when our login screen
state appears on the screen of our device.
So now that we have a direct reference to our form state instance, we can go and look up the documentation
for form states like the actual form state class and just see how we can actually interact with this
form state that has been created.
Let's take a look at the documentation.
I think you'll see what I'm getting at.
OK, so I'm going to go back over to my FLEDER documentation.
I'm going to do a search for form states, here's the form state class.
And now that we have a direct reference to the instance of form state that is created, when we make
our form, we can look at all the different properties that are associated with this thing in all the
different methods that are associated with it as well.
So whereas before you and I could really only get access to the different constructors that are associated
with all these different widgets, we now have the ability to reference all these properties and call
all these methods things to the.
Thanks to the global key that we set up right here, so again, the global key gives us the ability
to reference a very specific widget and reference properties and call methods that are associated with
that widget.
So in the case of our form state class, we can look at the different methods that are associated with
this thing.
You'll notice that one method is called reset.
And if we call reset, then it's going to attempt to reset every form field that is a descendant of
that form.
So if we call reset on our form state class, I think that it should probably reset these two inputs
right here.
I think that even though that's not what our submit button is supposed to do, that might be a good
test just to make sure that this stuff is working the way we expect.
So I'm going to go to my.
Callback on the Smith button.
So here's the submit button, here's where we create the raised button widget and here's the on pressed
callback.
So on this thing right here, whenever this thing gets pressed, I'm going to attempt to reference the
form St. Instance and call the reset method on it.
So to do so, I'm going to reference first the form key, which is going to give us a reference to the
form state instance that is created to kind of back up or represent our form on the screen.
So we have we just reference to the key by by writing out form key and then to actually get a handle
on the form state instance right here we write out DOT current state.
So if you now hover over current state, you'll see that it returns to us the form state instance or
something of type form state, so form keeg, current state, this thing right here is our form state
instant's so on this I can call reset and now any time user press this button, it should attempt to
reset every field within our form.
So to test this out, I will do a full refresh with a shifter.
I will wait for the reload.
OK, I'll enter in some random email, some random password, and then when I click on the submit button,
I see that both my inputs got completely zeroed out or essentially reset back to their default initial
state where they have no value associated with them whatsoever.
All right.
So that's pretty much it.
That's how we get a handle on some particular widget that has been created inside of our application
and call a method associated with it or reference a property.
We use this global key thing right here.
We save the key and then we pass that key off to whatever element or whatever widget we want to get
our reference to.
So now that we have the ability to get a reference to our form state, we can now.
Go back to this diagram, so we now have access to our foreign states now, we can use that reference
to tell it to validate all the text form fields that are rendered inside the form.
So let's take a quick break and we'll tackle that in the next section.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.