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