single<T> static method

T? single<T>({
  1. required String title,
  2. required List<T> items,
  3. PromptTheme theme = PromptTheme.dark,
  4. int columns = 0,
  5. int? cellWidth,
  6. int? maxColumns,
  7. String labelBuilder(
    1. T
    )?,
})

Creates a single-select grid prompt.

Implementation

static T? single<T>({
  required String title,
  required List<T> items,
  PromptTheme theme = PromptTheme.dark,
  int columns = 0,
  int? cellWidth,
  int? maxColumns,
  String Function(T)? labelBuilder,
}) {
  final prompt = SelectableGridPrompt<T>(
    title: title,
    items: items,
    theme: theme,
    multiSelect: false,
    columns: columns,
    cellWidth: cellWidth,
    maxColumns: maxColumns,
  );

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