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