finishRequest method

void finishRequest({
  1. Map<String, dynamic>? response,
})

分页接口请求完成后执行,配置相关状态 response 分页数据对象,请求失败时不需要传入

Implementation

void finishRequest({Map<String, dynamic>? response}) {
  var nextFieldName = DioManager.instance.configInterceptor?.hasNextPageKey() ?? "";
  var hasNextPage = response?[nextFieldName] ?? false;
  if ((hasNextPage is! bool) || !hasNextPage) {
    isNoMore = true;
  } else {
    isNoMore = false;
  }
  var countFieldName = DioManager.instance.configInterceptor?.countKey() ?? "";
  _total = response?[countFieldName] ?? 0;
  if (_page == 1 && isNoMore && _total == 0) {
    isEmptyData = true;
  } else {
    isEmptyData = false;
  }
  var firstFieldName = DioManager.instance.configInterceptor?.isFirstPageKey() ?? "";
  var isFirstPage = response?[firstFieldName] ?? false;
  if ((isFirstPage is! bool) || isFirstPage) {
    super.clear();
  } else if ((hasNextPage is bool) && hasNextPage) {
    _page++;
  }
}