Skip to content

Extract a shared drink-count pluralisation helper #513

Description

@richardthe3rd

Summary

The count == 1 ? 'drink' : 'drinks' ternary is now inlined at four call sites, past the "extract a helper at 3+ repetitions" threshold in AGENTS.md.

Call sites

File Context
lib/widgets/festival_header.dart:21 '$drinkCount ${drinkCount == 1 ? 'drink' : 'drinks'}'
lib/screens/my_festival_screen.dart:210 section semantics label
lib/widgets/drink_filter_sheets.dart category row semantics label
lib/widgets/drink_filter_sheets.dart style row semantics label

The last two were added in #506 after review flagged that those labels announced "1 drinks" to screen readers.

Why it is worth doing

The failure mode is silent and accessibility-facing: a new label that forgets the ternary reads "1 drinks" to a screen reader and nothing fails. Two of the four sites had exactly that bug until it was caught in review, which is evidence the inline form does not survive copy-paste.

Suggested fix

A small helper — e.g. String drinkCountLabel(int count) in lib/utils/ — returning '$count drink' / '$count drinks', with a unit test covering 0, 1 and 2. Update all four sites.

Deliberately not done as part of #506: two of the four call sites are in files unrelated to that change, and widening the diff into them would have been scope creep.

Impact

Low. No user-visible defect today — all four sites are currently correct. This is about stopping the fifth one from being wrong.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions