datePickerEntry method
Implementation
Widget datePickerEntry({
String title = 'Date',
String subTitle = 'the date',
Function(DateTime?)? onChanged,
DateTime? firstDate,
DateTime? lastDate,
Function? onPressed,
DateTime? defaultValue,
}) {
return formEntry(
title: title,
subTitle: subTitle,
inputWidget: TertiaryFlatButton(
onPressed: () async {
onPressed?.call();
final DateTime? pickedDate = await showDatePicker(
context: context,
initialDate: defaultValue ?? firstDate,
firstDate: firstDate ?? DateTime(2021),
lastDate: lastDate ?? DateTime(2101),
);
onChanged?.call(pickedDate);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.watch_later_outlined),
SizedBox(width: smallPadding),
Text(
defaultValue != null
? '${defaultValue.day.toString().padLeft(2, '0')}-${defaultValue.month.toString().padLeft(2, '0')}-${defaultValue.year}'
: 'Select date',
style: Theme.of(context).textTheme.bodyLarge,
),
],
),
),
);
}