Categories
dart flutter one_liner software_dev

Convert TimeOfDay to DateTime

Simple convenience method to change a Flutter TimeOfDay object to a Dart DateTime object.

DateTime _timeOfDayToDateTime(
  TimeOfDay time, {
  int year = 1970,
  int month = 1,
  int day = 1,
}) =>
    DateTime(
      year,
      month,
      day,
      time.hour,
      time.minute,
    );