refresh method

Future refresh()

刷新

Implementation

Future refresh() async {
  onBegin?.call(false);
  page = 1;
  await HttpRequest().get(
    requestUrl,
    params: commonParams,
    options: requestOptions,
    cancelToken: cancelToken,
    onSuccess: (data) {
      page++;
      listData = jsonParse.call(data);
      if (listData.isEmpty) {
        easyRefreshController.finishRefresh();
        easyRefreshController.finishLoad(IndicatorResult.noMore);
      } else {
        easyRefreshController.finishRefresh();
        easyRefreshController.resetFooter();
      }
      onSuccess?.call(data, false);
    },
    onFailed: (code, error) {
      easyRefreshController.finishRefresh(IndicatorResult.fail);
      onFailed?.call(code, error, false);
    },
    onCommon: () {
      onCommon?.call(false);
    },
    bind: bind,
  );
}