resolveChipDisplayLabel<T> method

String resolveChipDisplayLabel<T>({
  1. required String label,
  2. required List<Choice<T>> selectedChoices,
  3. required bool singleSelection,
  4. required bool hasData,
})

Resolves the display label shown on the chip.

  • No selection → original label
  • Single selection → the selected item's value
  • Multi selection → "label (count)"

Implementation

String resolveChipDisplayLabel<T>({
  required String label,
  required List<Choice<T>> selectedChoices,
  required bool singleSelection,
  required bool hasData,
}) {
  if (selectedChoices.isEmpty || !hasData) return label;

  return singleSelection
      ? selectedChoices.first.value
      : '$label (${selectedChoices.length})';
}