STF: SOLD
Hi, I would like to thank everyone who has purchased some of my #NFTs recently. #eCash $XEC pic.twitter.com/Xxil6H6kbo
— Gaexe (@gaexe_) December 13, 2024
Text fields allow users to type text into an app. They are used to create forms, send messages, create search experiences, and much more. In this recipe, explore how to create and style text fields.
Flutter provides two text fields: TextField and TextFormField.
TextField
TextField is the most commonly used text input widget.
By default, the TextField is decorated with an underline. You can add a label, icon, single-line hint text, and error text by providing an InputDecoration
as the decoration property of TextField. To remove all decorations (including the underline and space allocated for the label), set the decoration to null
.
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Enter a search term',
),
),
TextFormField
TextFormField wraps TextField and integrates it with the attached Form. It provides additional functionality such as validation and integration with other FormField widgets.
TextFormField(
decoration: const InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Enter your username',
),
),