hookified_infinite_scroll_pagination 0.1.0 copy "hookified_infinite_scroll_pagination: ^0.1.0" to clipboard
hookified_infinite_scroll_pagination: ^0.1.0 copied to clipboard

flutter_hooks support for infinite_scroll_pagination

example/example.md

Simple Usage #

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
6
likes
140
points
25
downloads

Publisher

verified publisherkrtirtho.dev

Weekly Downloads

2024.07.06 - 2025.01.18

flutter_hooks support for infinite_scroll_pagination

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_hooks, infinite_scroll_pagination

More

Packages that depend on hookified_infinite_scroll_pagination