0
0
Fluttermobile~5 mins

TextFormField in Flutter - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a TextFormField in Flutter?
A TextFormField is a widget that allows users to enter and edit text in a form. It integrates with form validation and saving mechanisms.
Click to reveal answer
beginner
How do you validate user input in a TextFormField?
You provide a validator function that returns an error message string if the input is invalid, or null if it is valid.
Click to reveal answer
beginner
What property do you use to save the input value from a TextFormField?
Use the onSaved property, which takes a function to save the input value when the form is saved.
Click to reveal answer
intermediate
How can you control the text inside a TextFormField programmatically?
By using a TextEditingController assigned to the controller property of the TextFormField.
Click to reveal answer
intermediate
Why should you wrap TextFormField widgets inside a Form widget?
Wrapping inside a Form allows collective validation and saving of multiple fields together using a GlobalKey<FormState>.
Click to reveal answer
Which property of TextFormField is used to check if the input is valid?
Avalidator
BonChanged
Ccontroller
DonSaved
What does the onSaved callback do in a TextFormField?
AIt validates the input
BIt saves the input value when the form is saved
CIt clears the input field
DIt controls the keyboard type
Which widget should wrap TextFormField widgets to manage form state?
AScaffold
BContainer
CForm
DColumn
How do you programmatically change the text inside a TextFormField?
AUse a <code>TextEditingController</code>
BUse the <code>onChanged</code> callback
CUse the <code>validator</code> function
DUse the <code>onSaved</code> callback
What happens if the validator function returns a non-null string?
AThe form input is considered valid
BThe keyboard is dismissed
CThe input field is cleared
DThe form input is considered invalid and shows the error message
Explain how to use TextFormField inside a form to collect and validate user input.
Think about how you group fields and check their values before saving.
You got /5 concepts.
    Describe how TextEditingController works with TextFormField and why it might be useful.
    Consider when you want to change or read the text from code, not just user typing.
    You got /4 concepts.