Last updated:
0 purchases
hookified infinite scroll pagination
infinite_scroll_pagination Hooks #
Hookified variant of the package infinite_scroll_pagination
Installation #
$ flutter pub add hookified_infinite_scroll_pagination
copied to clipboard
You don't need infinite_scroll_pagination as hookified_infinite_scroll_pagination package already re-exports everything within infinite_scroll_pagination
Basic Usage #
Based on the EdsonBueno/infinite_scroll_pagination/example/example.md
class CharacterListView extends HookWidget {
static const _pageSize = 20;
@override
Widget build(BuildContext context) {
final _pagingController = usePagingController(
firstPageKey: 0,
onPageRequest: (pageKey, pagingController) async {
try {
final newItems = await RemoteApi.getCharacterList(pageKey, _pageSize);
final isLastPage = newItems.length < _pageSize;
if (isLastPage) {
pagingController.appendLastPage(newItems);
} else {
final nextPageKey = pageKey + newItems.length;
pagingController.appendPage(newItems, nextPageKey);
}
} catch (error) {
pagingController.error = error;
}
}
);
return PagedListView<int, CharacterSummary>(
pagingController: _pagingController,
builderDelegate: PagedChildBuilderDelegate<CharacterSummary>(
itemBuilder: (context, item, index) => CharacterListItem(
character: item,
),
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.