The TextField widget is used to accept text input from the user. It supports styling, placeholder text, validation, obscuring text (for passwords), and more.
Source Code
TextField(
controller: _controller,
decoration: InputDecoration(
labelText: 'Username',
hintText: 'Enter your username',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.person),
),
)
Ai Code Analizer
🎨 Common Properties
| Property | Description |
|---|---|
controller | Manages and retrieves the input text |
obscureText | Hides input (e.g., for passwords) |
keyboardType | Sets input type (e.g., TextInputType.emailAddress) |
maxLines | Allows multiline input if set > 1 |
decoration | Adds borders, hints, icons via InputDecoration |
onChanged | Callback for real-time input changes |
enabled | Set to false to make the field read-only |
