showDateTimePicker method

Future<DateTime?> showDateTimePicker(
  1. BuildContext context, [
  2. DateTime? value
])

Shows a date and time picker dialog and returns the selected date and time

Implementation

Future<DateTime?> showDateTimePicker(
  BuildContext context, [
  DateTime? value,
]) async {
  final initialDate = value ?? DateTime.now();

  final date = await showDatePicker(
    context: context,
    initialDate: initialDate,
    firstDate: start,
    lastDate: end,
  );
  if (date == null) return null;

  final time = await showTimePicker(
    context: context,
    initialTime: TimeOfDay.fromDateTime(initialDate),
  );
  if (time == null) return null;

  return DateTime(
    date.year,
    date.month,
    date.day,
    time.hour,
    time.minute,
  );
}