Should I set a value to every null fields when retrieving something something from an api? Or should I keep them null and check when displaying them if they aren't null?
Ex:
factory Geo.fromJson(Map<String, dynamic> json) => Geo(
type: json["type"] == null ? 'Point' : json["type"],
coordinates: json["coordinates"] == null ? [] : List<double>.from(json["coordinates"].map((x) => double.tryParse(x))),
);
or
factory Geo.fromJson(Map<String, dynamic> json) => Geo(
type: json["type"] == null ? null : json["type"],
coordinates: json["coordinates"] == null ? null : List<double>.from(json["coordinates"].map((x) => double.tryParse(x))),
);
Edit --> or should I be doing this in an other way like this maybe?
factory Location.fromJson(Map<String, dynamic> json) {
return Location(
geo: json["geo"] = Geo.fromJson(json["geo"]),
city: json["city"] = json["city"],
country: json["country"] = json["country"],
area: json["area"] = json["area"],
);
}