fl_paging 2.3.0 
fl_paging: ^2.3.0 copied to clipboard
A new Flutter package support paginating for Listview, Gridview and NestedScrollView
Paging #
A Flutter package that supports pagination(load infinite) for ListView, GridView
Demo #
![]()  | 
![]()  | 
![]()  | 
DataSource #
PageKeyedDataSource
To create a PagingListView or PagingGridView you will need create class which extended from PageKeyedDataSource.
When extended from PageKeyedDataSource, you will need override 2 methods is loadInitial and loadPageAfter.
Output of those function is a Tuple2 with item1 is List
Example: if your list start with page index is 0. -> on loadInitial output is Tuple2([...], 1) 1 is next page when load more item.
Example:
class ListViewDataSource extends paging.PageKeyedDataSource<int, Note> {
  NoteRepository noteRepository;
  ListViewDataSource(this.noteRepository);
  @override
  Future<Tuple2<List<Note>, int>> loadInitial(int pageSize) async {
    return Tuple2(await noteRepository.getNotes(0), 1);
  }
  @override
  Future<Tuple2<List<Note>, int>> loadPageAfter(int params, int pageSize) async {
    return Tuple2(await noteRepository.getNotes(params), params + 1);
  }
}
Display on UI #
To display on UI, currently you can use PagingListView or PagingGridView.
Example:
      ListViewDataSource dataSource = ListViewDataSource(NoteRepository());
      PagingListView<Note>(
        itemBuilder: (context, data, child) => NoteWidget(data),
        pageDataSource: dataSource,
      ),


