fetchCountry method

Future<void> fetchCountry()

Implementation

Future<void> fetchCountry() async {
  CountryResponse response = await service.countryServices.countryfetch();
  if (!response.result.status) {
    log(response.result.description);
    return;
  }
  ARMOYU.countryList.clear();

  for (APICountry country in response.response!) {
    ARMOYU.countryList.add(
      Country(
        countryID: country.countryID,
        name: country.name,
        countryCode: country.code,
        phoneCode: country.phonecode,
      ),
    );

    if (currentUser!.detailInfo == null) {
      log("İZİN YOK (COUNTRY)");
      return;
    }
    if (currentUser!.detailInfo!.value!.country.value != null) {
      if (country.countryID ==
          currentUser!.detailInfo!.value!.country.value!.countryID) {
        fetchProvince(
          currentUser!.detailInfo!.value!.country.value!.countryID,
          ARMOYU.countryList.length - 1,
        );
      }
    }
  }
}