datePicker static method
dynamic
datePicker({})
pick date with customization
Implementation
static datePicker(
{required BuildContext context,
required Function(String date) onSelected,
String? date,
String? minDate,
String? maxDate,
String format = Format.fyyyyMMdd}) {
showDatePicker(
context: context,
initialDate:
_isNullOrEmpty(date) ? DateTime.now() : stringToDateTime(date: date!),
firstDate: _isNullOrEmpty(minDate)
? DateTime(1950)
: stringToDateTime(date: minDate!),
lastDate: _isNullOrEmpty(maxDate)
? DateTime(3000)
: stringToDateTime(date: maxDate!),
).then((value) {
String selectedDate = "";
if (value != null) {
selectedDate = dateTimeToString(date: value, format: format);
} else {
selectedDate = _isNullOrEmpty(date)
? ""
: dateTimeFormat(
dateTime: date!, inFormat: format, outFormat: format);
}
onSelected(selectedDate);
});
}