decodeBoolOrNull method

  1. @override
bool? decodeBoolOrNull(
  1. String key, {
  2. int? id,
})
override

Decodes the data for the given key or id as a nullable boolean value.

Implementation

@override
bool? decodeBoolOrNull(String key, {int? id}) {
  try {
    return _value[key] as bool?;
  } on TypeError {
    throw CodableException.wrap(
      CodableException.unexpectedType(expected: 'bool?', actual: '${_value[key].runtimeType}', data: _value[key]),
      method: 'decode',
      hint: '["$key"]',
    );
  }
}