weekdayAsString function Null safety

String weekdayAsString(
  1. {required DateTime date}
)

Returns day of the week of given DateTime as a text String.

Implementation

String weekdayAsString({required DateTime date}) {
  var days = <int, String>{
    1: 'Monday',
    2: 'Tuesday',
    3: 'Wednesday',
    4: 'Thursday',
    5: 'Friday',
    6: 'Saturday',
    7: 'Sunday'
  };
  return days[date.weekday]!;
}