glossPlural function

String glossPlural(
  1. BuildContext context,
  2. int count, {
  3. String? zero,
  4. required String one,
  5. String? two,
  6. String? few,
  7. String? many,
  8. required String other,
})

The form of a counted phrase for count in context's language (its Localizations locale, else English): one and other at least, and zero, two, few and many for the languages that have them. A form the language uses but the caller left out falls back to other.

glossPlural(context, 3, one: '1 recipe', other: '3 recipes')

Implementation

String glossPlural(
  BuildContext context,
  int count, {
  String? zero,
  required String one,
  String? two,
  String? few,
  String? many,
  required String other,
}) {
  final locale = Localizations.maybeLocaleOf(context) ?? const Locale('en');
  return switch (glossPluralCategory(locale, count)) {
        GlossPluralCategory.zero => zero,
        GlossPluralCategory.one => one,
        GlossPluralCategory.two => two,
        GlossPluralCategory.few => few,
        GlossPluralCategory.many => many,
        GlossPluralCategory.other => other,
      } ??
      other;
}