callDealerDetailsApi method

Future<void> callDealerDetailsApi(
  1. String dealerId
)

Implementation

Future<void> callDealerDetailsApi(String dealerId) async {
  BuildContext context = Get.context!;
  Helper.progressDialog(context, "Please wait..");
  try {
    await ApiClient(baseUrl: ApiConstant.baseUrl)
        .getMoreInfo(dealerId: dealerId, xUserId: storage.read("XUSER_ID"))
        .then((response) async {
      DealerDetailsModel model = response;
      if (model.profile != null) {
        if (model.profile!.address != null) {
          regionName = model.profile!.address!.locationName4 ?? "";
        }

        storage.write("REGION_NAME", regionName);
        levelName = model.profile!.levelName ?? "";
        storage.write("LEVEL_NAME", levelName);
        storage.write("PARTNER_ID ", model.profile!.partnerId ?? "");
        levelId = model.profile!.levelId ?? 0;
        storage.write("LEVEL_ID", levelId);
        // levelId = 5;
        Get.back();
        await callDistributerLevelApi(levelId);
      } else {
        Get.back();
      }
    }, onError: (error) {
      print(error.toString());
      GenericResponse res = GenericResponse.fromJson(error?.response?.data);
      Get.back();
      Helper.messageDialog(
        Get.context!,
        res.responseCode ?? "Try Again!!",
        res.responseMessage ?? "Unknown error",
      );
    });
  } catch (err, stacktrace) {
    print(stacktrace);
    Get.back();
    Get.snackbar("Try Again!!", err.toString());
  }
}