fromJson static method
Implementation
static Answer fromJson(Map<String, dynamic> data) {
final dynamic value = data[keyResponse];
switch (value) {
case bool():
return Answer<bool>.parseJson(data);
case num():
return Answer<num>.parseJson(data);
case String():
return Answer<String>.parseJson(data);
default:
// todo Why does value has a type of List<dynamic> instead of List<String>?
if (value is List) {
data[keyResponse] = value.map((e) => e.toString()).toList();
return Answer<List<String>>.parseJson(data);
} else {
throw ArgumentError('Unknown answer type: ${value.runtimeType}');
}
}
}