coerceBool function

bool coerceBool(
  1. DartObject? value,
  2. String field, {
  3. required bool defaultTo,
})

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;