jsonDecodeAsyncMap<T> function
Helper method that uses jsonDecodeAsync
to decode the passed json
string
into a typed Map
. Because JSON dictionaries can only contain string keys,
the returned Map type is String,T
.
Implementation
Future<Map<String, T>> jsonDecodeAsyncMap<T>(String json) async {
return jsonDecodeAsync(json).then((value) {
if (value is Map) {
return Map<String, T>.from(value);
}
throw TypeError();
});
}