useSearchableSheetForOptions static method

bool useSearchableSheetForOptions({
  1. required List<String> normalized,
  2. QuestionOptionsPresentation? presentation,
  3. int? chipMaxCount,
})

Whether the UI should use the searchable sheet for this normalized option list.

Implementation

static bool useSearchableSheetForOptions({
  required List<String> normalized,
  QuestionOptionsPresentation? presentation,
  int? chipMaxCount,
}) {
  final mode = presentation ?? QuestionOptionsPresentation.automatic;
  final max = chipMaxCount ?? kDefaultOptionsChipMaxCount;
  switch (mode) {
    case QuestionOptionsPresentation.chips:
      return false;
    case QuestionOptionsPresentation.searchableSheet:
      return true;
    case QuestionOptionsPresentation.automatic:
      return normalized.length > max;
  }
}