convertToNumMap static method

Map<String, num> convertToNumMap(
  1. Map<String, dynamic> map
)

Implementation

static Map<String, num> convertToNumMap(Map<String, dynamic> map) {
  return Map.fromEntries(map.entries.map((entry) {
    if (entry.value is int || entry.value is double) {
      return MapEntry(entry.key, entry.value);
    } else if (entry.value is String && num.tryParse(entry.value) != null) {
      return MapEntry(entry.key, num.parse(entry.value));
    } else {
      throw Exception('Value for key ${entry.key} is not a number');
    }
  }));
}