TextField is a Flutter widget that lets users enter text. It offers a straightforward method for collecting user input data, including messages, passwords, and names.email etc,
It’s Typically used for gathering user input in forms eg SignUp, Signin, search bars, or any other context where text entry is necessary.
Key Features:
- Text input: Permits users to enter text.
- Customizable: Supports different styles, fonts, and colors.
- Validation: You Can validate user input using a
Form
widget. - Callbacks: Callbacks are provided for events such as text modifications, submissions, and focus shifts.
Example
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Name',
hintText: 'Enter your Name',
),
)
//This example creates a TextField with a border, hint text, and label. The updated text is printed by the onChanged callback // when the user types.
Common Properties In TextField
controller
: Controls the text input.decoration
: Customizes the appearance.keyboardType
: indicates the type of keyboard (e.g., email, phone).obscureText
: Hides the input text (e.g., for passwords).onSubmitted
: called upon text submission by the user.