toHumanReadableText method

String toHumanReadableText({
  1. DateTime? startDate,
  2. RruleL10n? localization,
  3. SupportedLanguage? language,
  4. String? languageCode,
})

Tries to convert this recurrence rule to human readable text

When you specify the optional startDate, the week day will be taken into account for recurrences with a weekly frequency.

You can specify the used localization directly, specify it via the language enum or set the languageCode. By default US American English is used.

For example RRULE:FREQ=WEEKLY;COUNT=10 would be converted to weekly, 10 times, or when the start date falls on a Tuesday, every Tuesday, for example.

Implementation

String toHumanReadableText({
  DateTime? startDate,
  RruleL10n? localization,
  SupportedLanguage? language,
  String? languageCode,
}) {
  final usedLocalization = localization ??
      ((language != null)
          ? RecurrenceRuleToTextEncoder.getForLanguage(language)
          : RecurrenceRuleToTextEncoder.getForLanguageCode(
              languageCode ?? 'en'));
  final encoder = RecurrenceRuleToTextEncoder(usedLocalization);

  return encoder.convert(this, startDate: startDate);
}