customDatePicker function
Future<DateTime> customDatePicker ({required DateTime initialDate})
Shows a dialog containing a Material Design date picker.
The returned Future resolves to the date selected by the user when the user confirms the dialog. If the user cancels the dialog, null is returned.
Implementation
Future<DateTime> customDatePicker({required DateTime initialDate}) async {
// showDatePicker which shows a material design date range picker used to select a range of dates.
final DateTime? picked = await showDatePicker(
context: navigationService.navigatorKey.currentContext!,
initialDate: initialDate,
firstDate: DateTime(2015, 8),
lastDate: DateTime(2101),
);
if (picked != null && picked != initialDate) {
return picked;
}
return initialDate;
}