getMethodPagination method

Future<Response?> getMethodPagination({
  1. required IAuthHelper authHelper,
  2. required DropDownApiConfig dropDownConfig,
  3. required int pageNumber,
  4. required bool isPagination,
  5. String? searchString,
})

Method used same as above but this method is enhance with client for cancellation pending request if pending

Implementation

Future<Response?> getMethodPagination(
    {required IAuthHelper authHelper,
    required DropDownApiConfig dropDownConfig,
    required int pageNumber,
    required bool isPagination,
    String? searchString}) async {
  String urlBuild = "";
  if (isPagination) {
    urlBuild =
        "${dropDownConfig.getUrl()}?${dropDownConfig.getSearchKeyNameInUrl()}=${searchString ?? ""}&page=$pageNumber&size=${dropDownConfig.singlePageSize()}&locationId=&sort=firstName,asc";
  } else {
    urlBuild =
        "${dropDownConfig.getUrl()}?size=${dropDownConfig.singlePageSize()}&sort=firstName,asc";
  }

  Response? response;
  response = await http.get(
    Uri.parse(urlBuild),
    headers: {
      "content-type": "application/json",
      "accept": "application/json",
      'Authorization': await authHelper.getToken(),
    },
  );
  return response;
}