attributesFromJson function

Map<String, dynamic> attributesFromJson(
  1. Map<String, dynamic> json
)

Implementation

Map<String, dynamic> attributesFromJson(Map<String, dynamic> json) {
  if (json.length != 1) {
    throw Exception("JSON element must have a single key");
  }
  final key = json.keys.first;
  final val = json[key];
  if (val is Map<String, dynamic>) {
    return Map<String, dynamic>.from(val);
  } else {
    throw Exception("JSON element value must be an object");
  }
}