coerceBool function
Reads and returns field
on value
as a boolean.
Unlike DartObject#getField
, this also traverses super
if available.
If the value is missing or is not a boolean, returns defaultTo
.
Implementation
bool coerceBool(DartObject? value, String field, {required bool defaultTo}) =>
getField(value, field)?.toBoolValue() ?? defaultTo;