readDouble function
Typed readers over a component or material property bag, with fallbacks
for missing or mistyped values. Shared by component codecs and the
resource realizer.
Reads a double property, accepting an int too, or returns fallback.
Implementation
/// Reads a `double` property, accepting an int too, or returns [fallback].
double readDouble(
Map<String, PropertyValue> props,
String key,
double fallback,
) {
final v = props[key];
return switch (v) {
DoubleValue(:final value) => value,
IntValue(:final value) => value.toDouble(),
_ => fallback,
};
}