Country.fromJosn constructor

Country.fromJosn(
  1. Map<String, dynamic> json
)

Implementation

factory Country.fromJosn(Map<String, dynamic> json) => Country(
      alpha2Code: json['alpha2Code'],
      alpha3Code: json['alpha3Code'],
      altSpellings: json['altSpellings'].toString() != '[]'
          ? json['altSpellings'].cast<String>()
          : [],
      area: (json['area'] as num?)?.toDouble(), // area in kmĀ²
      borders: json['borders'].toString() != '[]'
          ? json['borders']?.cast<String>()
          : [],
      callingCodes: json['callingCodes'].toString() != '[]'
          ? json['callingCodes'].cast<String>()
          : [],
      capital: json['capital'] as String?,
      currnecies: json['currencies'].toString() == '[]'
          ? null
          : CurrencyList.fromJson(json['currencies']),
      demonym: json['demonym'] ?? '',
      independent: json['independent'] as bool?,
      flagIcon: getFlagByCountryCode(json['alpha2Code']),
      flags: json['flags'].toString() != '[]'
          ? json['flags'].cast<String>()
          : [],
      // gini goes here
      // languages: json['languages'] as List<Map<String, String>>,
      latitude: json['latlng'].toString() != '[]'
          ? double.parse(json['latlng'][0].toString())
          : null,
      longitude: json['latlng'].toString() != '[]'
          ? double.parse(json['latlng'][1].toString())
          : null,
      // maps goes here
      name: json['name'],
      nativeName: json['nativeName'] ?? '',
      numericCode: json['numericCode'] as String?,
      // population geos here
      // continent geos here
      // regionalBlocs  geos here
      region: json['region'],
      timeZones: TimeZoneList.fromJson(json['timezones']),
      topLevelDomain: json['topLevelDomain'].cast<String>(),
      translations: json['translations'].toString() == '{}'
          ? null
          : json['translations'] as Map<String,String>?,
      // cioc  geos here
      //countries that share borders with this country
    );