boolean method

bool boolean(
  1. String key, {
  2. bool? defaultValue,
})

Extracts a boolean value.

Returns the boolean value corresponding to the key.

The key must exist in the map or a defaultValue is provided. Otherwise, a ConfigExceptionKeyMissing exception will be thrown.

To allow the key to be missing, use the booleanOptional method.

Default value

When a defaultValue is provided a value is always returned. So while the key does not have to appear in the config, there is always a value available. To the config it is optional, but to the program it behaves the same as a mandatory key.

Implementation

bool boolean(String key, {bool? defaultValue}) =>
    _boolean(key, optional: false, defaultValue: defaultValue)!;