how to add model to list in flutter from json code example
Example: how to parse an array of json objects in flutter
Map<String, dynamic> json = jsonDecode(rawJson);
List<Location> locations = List<Location>.from(json["locations"].map((x) => Location.fromJson(x)))
class Location {
Location({
this.name,
this.days,
});
String name;
List<int> days;
factory Location.fromJson(Map<String, dynamic> json) => Location(
name: json["name"],
days: List<int>.from(json["days"].map((x) => x)),
);
Map<String, dynamic> toJson() => {
"name": name,
"days": List<dynamic>.from(days.map((x) => x)),
};
}