extractRevenue function
Implementation
double? extractRevenue(String key, Map<String, dynamic> properties) {
final value = properties[key];
if (value == null) {
return null;
}
// If value is numeric (int or double), convert to double.
if (value is num) {
return value.toDouble();
} else if (value is String) {
// Attempt to parse the string into a double.
return double.tryParse(value);
}
// If it is neither numeric nor a valid string, return null.
return null;
}