fl_paging 1.0.5
fl_paging: ^1.0.5

Flutter Android iOS web

A new Flutter package support paginating for Listview, Gridview and NestedScrollView

Paging #

Pub Package
Star on GitHub style: effective dart MIT License


A new Flutter package for paging

Demo #

DataSource #

PageKeyedDataSource

Example for load with page index

1, Define Source

class ListViewDataSource extends paging.PageKeyedDataSource<int, Note> {
  NoteRepository noteRepository;
  ListViewDataSource(this.noteRepository) {
    isEndList = false;
  }

  @override
  Future<Tuple2<List<Note>, int>> loadInitial() async {
    final result = await noteRepository.getNotes(0);
    return Tuple2(result, 0);
  }

  @override
  Future<Tuple2<List<Note>, int>> loadPageAfter(int params) async {
    if (params == 6) isEndList = true;
    final result = await noteRepository.getNotes(params + 1);
    return Tuple2(result, params + 1);
  }
}

2, ListView

      ListView<Note>(
        key: key,
        padding: EdgeInsets.all(16),
        itemBuilder: (context, data, child) {
          return NoteWidget(data);
        },
        pageDataSource: dataSource,
      ),

3, GridView

      paging.GridView<Note>(
        key: key,
        padding: EdgeInsets.all(16),
        itemBuilder: (context, data, child) {
          return NoteGridWidget(data);
        },
        delegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
          mainAxisSpacing: 16,
          crossAxisSpacing: 16
        ),
        pageDataSource: dataSource,
      ),

ItemKeyedDataSource

Coming Soon :))

OffsetDataSource

Coming Soon :))

IndexDataSource

Coming Soon :))

Documentation #

BaseWidget Class #

Dart attributeDescriptionDefault Value
emptyBuilderbuilder for empty widget
loadingBuilderbuilder for loading widget
errorBuilderbuilder for error widget
itemBuilderbuilder for item widget
pageDataSourceDataSource for this widget
4
likes
100
pub points
8%
popularity

Publisher

dangngocduc.dev

A new Flutter package support paginating for Listview, Gridview and NestedScrollView

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (LICENSE)

Dependencies

flutter, freezed_annotation, tuple

More

Packages that depend on fl_paging