countryDataToJson function
Converts a list of CountryData objects into a JSON string.
This function takes a list of CountryData objects, converts each into a map
using the toJson
method, and then encodes this list of maps as a JSON string.
Parameters:
data
- The list of CountryData objects to be converted into a JSON string.
Returns: A JSON string representation of the list of CountryData objects.
Implementation
String countryDataToJson(List<CountryData> data) =>
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));