ecp_paging 0.0.8+3
ecp_paging: ^0.0.8+3 copied to clipboard
分页组件库,整合下拉刷新与上拉加载,自动管理分页状态,支持自定义缺省页、控制器灵活配置。
ecp_paging #
ecp_paging是一个分页组件库,整合下拉刷新 & 上拉加载,自动管理分页的组件
使用方式 #
添加依赖 #
ecp_paging: ^<版本号>
简单使用 #
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<List<String>?> 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)
- footer:加载更多尾部组件(详见:EasyRefresh)
- 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:获取对应位置的数据
此库专为内部项目需求设计,若不符合您的使用场景,敬请谅解。