getBooleanInput function

bool getBooleanInput({
  1. required String name,
  2. InputOptions options = const InputOptions(),
})

Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.

Supported boolean input list: true | True | TRUE | false | False | FALSE .

Implementation

bool getBooleanInput({
  required String name,
  InputOptions options = const InputOptions(),
}) {
  const trueValues = {'true', 'True', 'TRUE'};
  const falseValues = {'false', 'False', 'FALSE'};

  final val = getInput(name: name, options: options);
  if (trueValues.contains(val)) {
    return true;
  } else if (falseValues.contains(val)) {
    return false;
  }

  throw StateError(
    'Input does not meet YAML 1.2 "Core Schema" specification: $name\n'
    'Supported boolean input list: `true | True | TRUE | false | False | FALSE`',
  );
}