emailFormEntry method
Implementation
Widget emailFormEntry({
String title = 'Email',
String subTitle = 'the email address',
Function(String?)? onSaved,
String? defaultValue,
bool verified = false,
bool showVerifyButton = true,
VoidCallback? onVerify,
}) {
return formEntry(
title: title,
subTitle: subTitle,
inputWidget: showVerifyButton
? Row(
children: [
Expanded(
child: TextFormField(
style: Theme.of(context).textTheme.bodyLarge,
onChanged: (_) {
widget.formKey.currentState!.save();
if (widget.onModified != null) {
widget.onModified!();
}
},
enabled: isEdit,
controller: TextEditingController(text: defaultValue),
decoration: elegantInputDecoration(
hintText: 'Email',
prefix: const Icon(Icons.email),
),
validator: (value) => value!.isEmpty
? 'Email is required'
: (value.isValidEmail() ? null : 'Invalid email'),
onSaved: onSaved,
),
),
if (verified)
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Icon(Icons.check_circle, color: Colors.green),
)
else if (showVerifyButton)
Padding(
padding: EdgeInsets.only(left: smallPadding),
child: SecondaryFlatButton(
onPressed: onVerify,
child: const Text('Verify'),
),
)
else
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Icon(Icons.check_circle, color: Colors.transparent),
),
],
)
: TextFormField(
style: Theme.of(context).textTheme.bodyLarge,
onChanged: (_) {
widget.formKey.currentState!.save();
if (widget.onModified != null) {
widget.onModified!();
}
},
enabled: isEdit,
controller: TextEditingController(text: defaultValue),
decoration: elegantInputDecoration(
hintText: 'Email',
prefix: const Icon(Icons.email),
),
validator: (value) => value!.isEmpty
? 'Email is required'
: (value.isValidEmail() ? null : 'Invalid email'),
onSaved: onSaved,
),
);
}