paginated_bloc_widget library
A powerful, flexible, and production-ready pagination widget for Flutter using BLoC pattern.
This package provides a complete solution for implementing infinite scroll pagination with support for ListView, GridView, PageView, CustomScrollView, and Slivers.
Features
- Generic type support for any data model
- Multiple layout types (ListView, GridView, PageView, Slivers)
- Built-in loading, error, and empty states
- Pull-to-refresh support
- Customizable threshold for triggering load more
- Easy to extend with custom repositories
Usage
BlocProvider(
create: (context) => PaginatedDataBloc<MyModel>(
repository: MyRepository(),
)..add(const LoadFirstPage()),
child: PaginatedDataWidget<MyModel>(
itemBuilder: (context, item, index) => ListTile(
title: Text(item.name),
),
),
)
Classes
-
AddItem<
T> - Event to add a new item to the list.
-
InMemoryPaginatedRepository<
T> - A simple in-memory repository implementation for testing purposes.
- LoadFirstPage
- Event to load the first page of data.
- LoadMoreData
- Event to load more data (next page).
-
PaginatedDataBloc<
T> - A generic BLoC for handling paginated data with any data type.
- PaginatedDataEvent
- Base class for all pagination events.
-
PaginatedDataRepository<
T> - Abstract repository for fetching paginated data.
-
PaginatedDataState<
T> - State class for PaginatedDataBloc.
-
PaginatedDataWidget<
T> - A flexible widget for displaying paginated data with various layout types.
-
PaginatedResponse<
T> - A response model for paginated data from any data source.
- PaginationConfig
- Configuration class for pagination settings.
- RefreshData
- Event to refresh the data.
-
RemoveItem<
T> - Event to remove an item from the list.
- ResetPagination
- Event to reset pagination to initial state.
-
UpdateItem<
T> - Event to update an existing item in the list.
Enums
- PaginatedLayoutType
- Layout types supported by PaginatedDataWidget.
- PaginationStatus
- Status enum representing all possible states during pagination.
- ScrollDirection
- Scroll direction for the paginated widget.