Country.fromJson constructor

Country.fromJson(
  1. Map<String, dynamic> data
)

Convert Countries.countryList to Country model

Implementation

factory Country.fromJson(Map<String, dynamic> data) {
  return Country(
    name: data['en_short_name'],
    alpha2Code: data['alpha_2_code'],
    alpha3Code: data['alpha_3_code'],
    dialCode: data['dial_code'],
    flagUri: 'assets/flags/${data['alpha_2_code'].toLowerCase()}.png',
    nameTranslations: data['nameTranslations'] != null
        ? Map<String, String>.from(data['nameTranslations'])
        : null,
  );
}