extractAmount static method
Extracts a numeric amount from a request body map, checking a few common field names. Returns null if no numeric amount is found.
Implementation
static double? extractAmount(dynamic body) {
if (body is! Map) return null;
for (final key in const ['amount', 'value', 'total']) {
final raw = body[key];
if (raw is num) return raw.toDouble();
if (raw is String) {
final parsed = double.tryParse(raw);
if (parsed != null) return parsed;
}
}
return null;
}