1. First create a StatefulWidget that returns a Form component in the Build method

Create a GlobalKey and set it to the key property of the Form

3, Create a form control TextFormField and add the implementation validator function to simply implement whether the user enters text

4. Add a button that triggers the validation function. If the user enters data, a SnackBar is processing it

Set the style of TextFormField

TextFormFiled has an attribute, decoration. The default is InputDecoration

InputBorder. None has no border. UnderlineInputBorder is the default border style. OutlineInputBorder has a line around it and can be set to corder, width, color, etc

(3)TextFormField automatically obtains focus and manually obtains focus

1. Automatically get focus, as long as the autofocus property is set to true

2. Manually get focus by defining a FocusNode object and assigning it to the FocusNode property of TextFormField

3. Add a button, manually start to get the focus, and call requestFocus

(4) Monitor the change of TextFormField text

Create a TextEditingController and assign it to the Controller property of TextFormField

2. Add a listener to the controller in initState

3. Get the value entered by the user through the text property of the controller

The last FocusNode and TextEditingController created release resources