getWeekName method
Extension method to get the name of a week from a given number.
Example usage:
1.getWeekName() => "Monday"
2.getWeekName(true) => "Tue"
@param isShort
If true, returns the short form of the week name. Default is false.
@return Returns the name of the week as a string. If the input number is not a valid week, returns "Invalid number of week".
Implementation
String getWeekName({bool isShort = false}) {
final Map<int, String> weekNames = <int, String>{
1: isShort ? 'Mon' : 'Monday',
2: isShort ? 'Tue' : 'Tuesday',
3: isShort ? 'Wed' : 'Wednesday',
4: isShort ? 'Thu' : 'Thursday',
5: isShort ? 'Fri' : 'Friday',
6: isShort ? 'Sat' : 'Saturday',
7: isShort ? 'Sun' : 'Sunday',
};
return weekNames[this] ?? 'Invalid number of week';
}