getLocations method

dynamic getLocations({
  1. int? locationType,
  2. String? parentId,
})

Implementation

getLocations({int? locationType, String? parentId}) async {
  String requestTime = "";
  String responseTime = "";
  var locations = await ApiClient(
    onFetchRequestTime: (time) {
      requestTime = time;
    },
    onFetchResponseTime: (time) {
      responseTime = time;
    },
    screenName: "customerManagement",
  ).getLocations(
      locationType: locationType, parentId: parentId, sort: "locationName");
  Helper.logEvent(
    "RESPONSE_EVENT",
    success: true,
    endPoint: Api.getlocations,
    responseDate: responseTime,
    screenName: "customerManagement",
    requestDate: requestTime,
  );
  if (locationType == 1) {
    country.clear();
    country.addAll(locations.content?.toList() ?? []);
    for (var location in country) {
      if (location.locationId ==
          partners.value.profile?.address?.locationId1) {
        selectedCountry.value = location;
        profileCountryController.text =
            selectedCountry.value.locationName ?? "";
      }
    }
  } else {
    regionDropdowns.clear();
    regionDropdowns.addAll(locations.content?.toList() ?? []);
    for (var location in regionDropdowns) {
      if (location.locationId ==
          partners.value.profile?.address?.locationId1) {
        selectedRegion.value = location;
      }
    }
  }
}