# ecp_paging **Repository Path**: kitman/ecp_paging ## Basic Information - **Project Name**: ecp_paging - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-07-25 - **Last Updated**: 2026-10-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ecp_paging ecp_paging是一个分页组件库,整合下拉刷新 & 上拉加载,自动管理分页的组件 ## 使用方式 ### 添加依赖 ``` ecp_paging: ^<版本号> ``` ### 简单使用 ``` dart Paging( controller: controller, ///分页控制器 task: () => testTask(), ///异步请求数据源 child: GridView.builder( itemBuilder: (context, index) => Padding( padding: const EdgeInsets.all(12), child: Center( child: Text("${controller.getItem(index)} $index"), ), ), itemCount: controller.list.length, gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 120), ), ) ... ///模拟数据源异步获取数据 Future?> testTask() async { await Future.delayed(const Duration(seconds: 2)); if (controller.currentPageIndex == 3) { return []; } return List.filled(10, "position"); } ``` ## 功能说明 ### Paging 属性 - child:需要分页的列表组件,一般为ListView或者GridView - task:异步分页数据请求,一般为接口 - controller:分页组件控制器 - header:下拉刷新头部组件(详见:[EasyRefresh](https://pub.flutter-io.cn/packages/easy_refresh)) - footer:加载更多尾部组件(详见:[EasyRefresh](https://pub.flutter-io.cn/packages/easy_refresh)) - initStatus:初始缺省状态,例如Loading,Error,Empty - autoRefresh:控制是否组件执行initState时执行刷新 - enableRefresh:开启下拉刷新 - enableLoadMore:开启上拉加载 - factory:默认缺省页 ### PagingController 说明 - firstPageIndex:起始分页页数 - currentPageIndex:当前分页页数 - list:当前分页数据模型列表 - listNotify:当前分页数据模型列表通知 - listNotify:当前分页数据模型列表通知 - listNotify:当前分页数据模型列表通知 - refresh:刷新方法,[cleanList]设置为true刷新时,会清除当前列表数据并显示[PagingStatus.loading]对应的缺省页,[silence]设置为true时,不会显示下拉刷新头,防止列表滑动至顶部;若设置了[cleanList]为true,则[silence]无效 - loadMore:上拉加载方法 - refreshList:手动刷新列表 - addList:手动增加列表项 - getItem:获取对应位置的数据 > 此库专为内部项目需求设计,若不符合您的使用场景,敬请谅解。