getApiSearchData method

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

Implementation

Future<ResponseModel?> getApiSearchData(
    {required IAuthHelper authHelper,
    required DropDownApiConfig dropDownConfig,
    required int pageNumber,
    bool isPagination = true,
    String? searchString}) async {
  ResponseModel? responseModel;
  try {
    Response? response = await ApiHelper().getMethodPagination(
        authHelper: authHelper,
        dropDownConfig: dropDownConfig,
        pageNumber: pageNumber,
        isPagination: isPagination,
        searchString: searchString);
    if (response != null &&
        (response.statusCode == 200 || response.statusCode == 201)) {
      responseModel = ResponseModel.fromJson(json.decode(response.body),
          idFindKey: dropDownConfig.getIdKey(),
          valueFindKey: dropDownConfig.getValueKey());
      return responseModel;
    }
  } catch (e) {
    return null;
  }
  return null;
}