formatRangeEndDate function

String formatRangeEndDate(
  1. MaterialLocalizations localizations,
  2. Jalali? startDate,
  3. Jalali? endDate,
  4. Jalali? currentDate,
)

Returns an locale-appropriate string to describe the end of a date range.

If endDate is null, then it defaults to 'End Date', otherwise if it is in the same year as the startDate and the currentDate then it will just use the short month day format (i.e. 'Jan 21'), otherwise it will include the year (i.e. 'Jan 21, 2020').

Implementation

String formatRangeEndDate(MaterialLocalizations localizations,
    Jalali? startDate, Jalali? endDate, Jalali? currentDate) {
  return endDate == null
      ? 'تاریخ پایان'
      : (startDate != null &&
              startDate.year == endDate.year &&
              startDate.year == currentDate!.year)
          ? endDate.formatShortMonthDay()
          : endDate.formatShortDate();
}