nameFormEntry method
Implementation
Widget nameFormEntry({
String title = 'Name',
String subTitle = 'the name',
Function(String?)? onSaved,
String? Function(String?)? validator,
String? defaultValue,
}) {
return formEntry(
title: title,
subTitle: subTitle,
inputWidget: TextFormField(
onChanged: (_) {
widget.formKey.currentState!.save();
if (widget.onModified != null) {
widget.onModified!();
}
},
style: Theme.of(context).textTheme.bodyLarge,
enabled: isEdit,
controller: TextEditingController(text: defaultValue),
decoration: elegantInputDecoration(
hintText: 'Name',
prefix: const Icon(Icons.person),
),
validator:
validator ??
(value) => value!.isEmpty
? 'Name is required'
: (value.isValidName() ? null : 'Invalid name'),
onSaved: onSaved,
),
);
}