countryDataFromJson function
Converts a JSON string into a list of CountryData objects.
This function decodes the given JSON string and uses the fromJson
constructor
of the CountryData class to create a list of instances.
Parameters:
str
- A JSON string representation of a list of CountryData objects.
Returns: A list of CountryData instances populated with data from the given JSON string.
Implementation
List<CountryData> countryDataFromJson(String str) => List<CountryData>.from(
json.decode(str).map((x) => CountryData.fromJson(x)));