toMap<T> function Null safety

Map<String, T> toMap<T>(
  1. dynamic value,
  2. DynTransformer<T> txr
)

Converts a dynamic json value into a map, using the provided transformer to convert

Implementation

Map<String, T> toMap<T>(value, DynTransformer<T> txr) {
  if (value is Map) {
    return value.map((key, item) {
      return MapEntry("$key", txr(item));
    });
  } else {
    throw ArgumentError("Expected map value");
  }
}