confirmSelect function

bool confirmSelect(
  1. dynamic prompt, {
  2. String? yes,
  3. String? no,
  4. StyleFunction? promptStyle,
  5. StyleFunction? yesStyle,
  6. StyleFunction? noStyle,
  7. bool? defaultValue,
  8. int? value,
})

Implementation

bool confirmSelect(
  prompt, {
  String? yes,
  String? no,
  StyleFunction? promptStyle,
  StyleFunction? yesStyle,
  StyleFunction? noStyle,
  bool? defaultValue,
  int? value,
}) {
  // Defaults
  yes ??= 'Yes';
  no ??= 'No';

  // Apply custom styles
  prompt = promptStyle?.call(prompt) ?? prompt;
  yes = yesStyle?.call(yes) ?? yes;
  no = noStyle?.call(no) ?? no;

  final result = selectOne<String>(
    prompt,
    choices: [yes, no],
    defaultValue: defaultValue == true ? yes : no,
    value: value,
  );

  return result == yes;
}