getDayAbbreviation function

String getDayAbbreviation(
  1. int dayIndex
)

Implementation

String getDayAbbreviation(int dayIndex) {
  const List<String> dayAbbreviations = [
    'Mon',
    'Tue',
    'Wed',
    'Thu',
    'Fri',
    'Sat',
    'Sun',
  ];

  // Check if the dayIndex is within a valid range
  if (dayIndex >= 1 && dayIndex <= 7) {
    return dayAbbreviations[dayIndex - 1];
  } else {
    // Return an empty string or handle the error as needed
    return '';
  }
}