Skip to content

Latest commit

 

History

History
68 lines (48 loc) · 1.74 KB

README_ZH.md

File metadata and controls

68 lines (48 loc) · 1.74 KB

flutter_paging pub package

分布加载,实现数据与UI解耦。

Note: 这个项目还处于开发阶段. 欢迎Pull Requests.

安装

首先, 添加 flutter_paging,参加dependency in your pubspec.yaml file.

Widgets

  • PagingView : 分页组件基础控件.

  • PagingListView : PagingView的子类,包裹了ListView.

KeyedDataSource

KeyedDataSource 分页的核心,数据的获取由dataSource完成。

Note: 不要忘记调用 dataSource.init()

Example

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Paging ListView"),
      ),
      body: RefreshIndicator(
        onRefresh: widget.dataSource.refresh,
        child: PagingListView<String>.builder(
          itemBuilder: (context, index, item) {
            return Card(
                child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text("paging->$item"),
            ));
          },
          dataSource: widget.dataSource,
          loadingIndicator: Center(
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: CircularProgressIndicator(),
            ),
          ),
          noMoreDataAvailableItem: Center(
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text("no more data avaliable~"),
            ),
          ),
        ),
      ),
    );
  }