jsonDecodeAsMap<T extends Object> function

Map<String, T> jsonDecodeAsMap<T extends Object>(
  1. String json, [
  2. Map<String, T> defaultValue = const {}
])

json decoding.

Only maps are output. If it is not a map, null is output.

If Json cannot be converted, defaultValue will be returned.

Implementation

Map<String, T> jsonDecodeAsMap<T extends Object>(String json,
    [Map<String, T> defaultValue = const {}]) {
  try {
    return (jsonDecode(json) as Map<String, dynamic>).cast<String, T>();
    // ignore: empty_catches
  } catch (e) {}
  return defaultValue;
}