safeGetDouble static method
Safely extracts a double value from a map with fallback.
This method centralizes the safe double extraction pattern that was repeated throughout the codebase for coordinate and confidence values.
map
The map to extract from
key
The key to extract
fallback
The fallback value if extraction fails
Returns the extracted double value or fallback
Implementation
static double safeGetDouble(
Map<dynamic, dynamic> map,
String key, {
double fallback = 0.0,
}) {
final value = map[key];
if (value is num) {
return value.toDouble();
}
return fallback;
}