single<T> static method

T? single<T>({
  1. required String title,
  2. required List<T> items,
  3. PromptTheme theme = PromptTheme.dark,
  4. int maxVisible = 10,
  5. String labelBuilder(
    1. T
    )?,
  6. bool searchEnabled = true,
})

Creates a single-select searchable prompt.

Implementation

static T? single<T>({
  required String title,
  required List<T> items,
  PromptTheme theme = PromptTheme.dark,
  int maxVisible = 10,
  String Function(T)? labelBuilder,
  bool searchEnabled = true,
}) {
  final prompt = SearchableListPrompt<T>(
    title: title,
    items: items,
    theme: theme,
    multiSelect: false,
    maxVisible: maxVisible,
    searchEnabled: searchEnabled,
  );

  final result = prompt.run(itemLabel: labelBuilder);
  return result.isEmpty ? null : result.first;
}