callDealerDetailsApi method

Future<void> callDealerDetailsApi(
  1. String dealerId
)

Implementation

Future<void> callDealerDetailsApi(String dealerId) async {
  BuildContext context = Get.context!;
  WidgetsBinding.instance.addPostFrameCallback((_) {
    Helper.progressDialog(context, "Please wait..");
  });
  await ApiClient(baseUrl: ApiConstant.baseUrl)
      .getMoreInfo(dealerId: dealerId, xUserId: storage.read("XUSER_ID"))
      .then((response) async {
    try {
      Get.back();
      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;
        await callDistributerLevelApi(levelId);
      }
    } catch (err, stacktrace) {
      print(stacktrace);
      Get.snackbar("Try Again!!", err.toString());
    }
  }, onError: (error) {
    print(error.toString());
    Get.back();
    Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
  });
}