dateTimePicker static method
Picker definition that selects the date and time.
Implementation
static Future<DateTime> Function(BuildContext, DateTime) dateTimePicker(
{DateTime? startDate, DateTime? current, DateTime? endDate}) {
return (context, dateTime) async {
final now = dateTime;
final date = await showDatePicker(
context: context,
firstDate: startDate ?? now.subtract(const Duration(days: 365)),
initialDate: current ?? now,
lastDate: endDate ?? now.add(const Duration(days: 365)));
if (date != null) {
final time = await showTimePicker(
context: context,
initialTime: TimeOfDay.fromDateTime(current ?? now),
);
return _DateTimeTextField.combine(
date,
time ?? TimeOfDay.fromDateTime(now),
);
} else {
return current ?? now;
}
};
}