tryGetBool method

  1. @preferInline
bool? tryGetBool(
  1. String key, {
  2. bool? defaultValue,
})

Retrieves a bool value from the JSON map associated with the given key.

If the value associated with the key is already a bool, it returns that value. Otherwise, it returns defaultValue.

Unlike getBool, this method does not store the parsed or existing bool back into the JSON map.

Implementation

@preferInline
bool? tryGetBool(
  String key, {
  bool? defaultValue,
}) {
  final value = _json[key];
  if (value is bool) {
    return value;
  }
  return defaultValue;
}