transformJsonValueOrNull<T, R> function Null safety

T? transformJsonValueOrNull<T, R>(
  1. Map<String, dynamic> json,
  2. String key,
  3. T transform(
    1. R
    )
)

Implementation

T? transformJsonValueOrNull<T, R>(
  Map<String, dynamic> json,
  String key,
  T Function(R) transform,
) {
  if (json.containsKey(key) && json[key] != null) {
    return transform(getJsonValue(json, key));
  } else {
    return null;
  }
}