paging a small library
a small library support load infinite for listview – gridview on flutter.
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 attribute | description | default value |
---|---|---|
emptybuilder |
builder for empty widget |
|
loadingbuilder |
builder for loading widget |
|
errorbuilder |
builder for error widget |
|
itembuilder |
builder for item widget |
|
pagedatasource |
datasource for this widget |
Comments are closed.