asDoubleOr function

double asDoubleOr(
  1. Object? v,
  2. double fallback
)

Reads v as a double, accepting a JSON integer for it too (see asIntOr for why dart:convert can hand back either).

Implementation

double asDoubleOr(Object? v, double fallback) {
  if (v is double) return v;
  if (v is int) return v.toDouble();
  return fallback;
}