changeSelectCountry method

dynamic changeSelectCountry({
  1. required Country newCountry,
  2. required BuildContext context,
})

Implementation

changeSelectCountry(
    {required Country newCountry, required BuildContext context}) {
  selectedCountry = newCountry;

  if ((phoneNumber.phoneNumber ?? "").isNotEmpty &&
      (phoneNumber.phoneNumber ?? "").contains("-")) {
    String newPhoneNumber =
        "${selectedCountry?.dialCode}-${phoneNumber.phoneNumber!.toLowerCase().split("-")[1]}";
    phoneNumber = PhoneNumber(
      phoneNumber: newPhoneNumber,
      isoCode: "",
      dialCode: selectedCountry?.dialCode,
    );
  }
  resetFilter();
  update();
  Navigator.pop(context);
}