formatRangeEndDate function

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

Format the end date of a range. localizations is the MaterialLocalizations object to use for the formatting. startDate is the start date of the range. endDate is the end date of the range. currentDate is the current date. Returns the formatted end date.

Implementation

String formatRangeEndDate(
    MaterialLocalizations localizations,
    NepaliDateTime? startDate,
    NepaliDateTime? endDate,
    NepaliDateTime currentDate) {
  return endDate == null
      ? localizations.dateRangeEndLabel
      : (startDate != null &&
              startDate.year == endDate.year &&
              startDate.year == currentDate.year)
          ? NepaliDateFormat('MMMM d').format(endDate)
          : NepaliDateFormat.yMd().format(endDate);
}