Tá foirmeacha i bhformhór na n-aipeanna (logáil isteach, clárú, ionchur sonraí) ag iarraidh láimhseáil agus bailíochtú ionchur úsáideora. Soláthraíonn Flutter Form, TextFormField, bailitheoirí, agus rialaithe chun foirmeacha a thógáil agus a bhailíochtú — ríthábhachtach d'aon aip le ionchur úsáideora.
Form agus TextFormField
final _formKey = GlobalKey<FormState>(); // a key to access the form's state
Form(
key: _formKey,
child: Column(children: [
TextFormField(
decoration: InputDecoration(labelText: 'Email'),
validator: (value) { // VALIDATION logic
if (value == null || value.isEmpty) return 'Email required';
if (!value.contains('@')) return 'Invalid email';
return null; // null = valid
},
),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) { // run all validators
// all fields valid → submit
}
},
child: Text('Submit'),
),
]),
)
