Component - Custom validators
This UI component shows a simple form with a text input field that uses a custom validator function. The validator checks if the input text meets specific rules before allowing submission.
This UI component shows a simple form with a text input field that uses a custom validator function. The validator checks if the input text meets specific rules before allowing submission.
Scaffold
├─ AppBar
│ └─ Text
└─ Padding
└─ Form
└─ Column
├─ TextFormField
└─ ElevatedButtonvalidator: (value) {
if (value == null || value.length < 5) {
return 'Too short';
}
return null;
}
What happens if the user enters "abc"?validator: (value) {
if (value.isEmpty) {
return 'Cannot be empty';
}
}Pass the test and this pattern moves unknown