toMap method

JsonObjectMap toMap()

Converts this object object to a JSON like map.

Implementation

JsonObjectMap toMap() {
  final encodedBlocs = jsonEncode(
    regionalBlocs?.map((rb) => rb.acronym).toList(growable: false) ?? [],
  );

  return {
    "altSpellings": altSpellings,
    "areaMetric": areaMetric,
    "bordersCodes": ?bordersCodes,
    "capitalInfo": ?capitalInfo?.toMap(),
    "car": car.toMap(),
    "cioc": ?cioc,
    "code": code,
    "codeNumeric": codeNumeric,
    "codeShort": codeShort,
    "continent": continent.name,
    "currencies": ?currencies?.toIsoList(),
    "demonyms": demonyms.map((d) => d.toMap()).toList(growable: false),
    "emoji": emoji,
    "fifa": ?fifa,
    "gini": ?gini?.toMap(),
    "hasCoatOfArms": hasCoatOfArms,
    "idd": idd.toMap(),
    "independent": independent,
    "landlocked": landlocked,
    "languages": languages.toIsoList(),
    "latLng": latLng.toMap(),
    "maps": maps.toMap(),
    "name": name.toMap(),
    "namesNative": namesNative
        .map((nn) => nn.toMap())
        .toList(growable: false),
    "population": population,
    "postalCode": ?postalCode?.toMap(),
    "regionalBlocs": ?(encodedBlocs.isEmpty ? null : encodedBlocs),
    "startOfWeek": startOfWeek.toMap(),
    "subregion": ?subregion?.name,
    "timezones": timezones,
    "tld": tld,
    "unMember": unMember,
  };
}