InfiniteListState<T extends JsonModel, TF extends DataFilter, TW extends StatefulWidget> class
abstract
An abstract state class that provides infinite scroll list functionality.
This template class implements a complete infinite scroll list with:
- Pagination support using
PagingController - Search functionality with animated search bar
- Filter support with optional filter form
- Pull-to-refresh capability
- Error handling including 403 forbidden state
- Empty state display
- Loading indicators
Subclasses must implement:
- filter: The data filter instance
- title: The page title
- repository: The repository for fetching data
- itemRender: Method to render each list item
- onIndexChange: Handler for index changes
Usage:
class MyListPageState extends InfiniteListState<MyModel, MyFilter, MyListPage> {
@override
MyFilter filter = MyFilter();
@override
String get title => 'My List';
@override
BaseRepository<MyModel, MyFilter> get repository => myRepository;
@override
Widget itemRender(BuildContext context, MyModel item, int index) {
return ListTile(title: Text(item.name));
}
@override
void onIndexChange() {
// Handle index change
}
}
Constructors
Properties
- context → BuildContext
-
The location in the tree where this widget builds.
no setterinherited
- filter ↔ TF
-
The data filter instance used for querying data.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isForbidden ↔ bool
-
Whether the current user is forbidden from accessing this list.
getter/setter pair
- isSearching ↔ bool
-
Whether the search bar is currently active.
getter/setter pair
-
list
→ List<
T> -
Gets the current list of loaded items.
no setter
- mounted → bool
-
Whether this State object is currently in a tree.
no setterinherited
-
pagingController
→ PagingController<
int, T> -
Paging controller that manages pagination state and data loading.
final
-
repository
→ BaseRepository<
T, TF> -
The repository used to fetch and count data.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- searchController → TextEditingController
-
Text editing controller for the search input.
final
- searchFocus → FocusNode
-
Focus node for the search text field.
final
- shouldShowCreateButton → bool
-
Whether to show the create button (floating action button).
no setter
- shouldShowFilterButton → bool
-
Whether to show the filter button in the app bar.
no setter
- title → String
-
The title to display in the app bar.
no setter
- total ↔ int
-
The total count of items available (before pagination).
getter/setter pair
- widget → TW
-
The current configuration.
no setterinherited
Methods
-
activate(
) → void -
Called when this object is reinserted into the tree after having been
removed via deactivate.
inherited
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
buildEmptyListIndicator(
BuildContext context) → Widget - Builds the indicator shown when the list is empty.
-
buildFirstPageErrorPageIndicator(
BuildContext context) → Widget - Builds the error indicator shown when loading the first page fails.
-
buildFirstPageProgressIndicator(
BuildContext context) → Widget - Builds the progress indicator shown while loading the first page.
-
buildNewPageProgressIndicator(
BuildContext context) → Widget - Builds the progress indicator shown while loading subsequent pages.
-
buildNextPageErrorPageIndicator(
BuildContext context) → Widget - Builds the error indicator shown when loading a subsequent page fails.
-
cancelSearchBar(
) → void - Cancels the search by clearing the search query and deactivating search mode.
-
clearFilter(
) → void - Clears the current filter and refreshes the list.
-
countRender(
num count) → Widget - Renders the item count display.
-
deactivate(
) → void -
Called when this object is removed from the tree.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
didChangeDependencies(
) → void -
Called when a dependency of this State object changes.
inherited
-
didUpdateWidget(
covariant TW oldWidget) → void -
Called whenever the widget configuration changes.
inherited
-
dispose(
) → void -
Called when this object is removed from the tree permanently.
override
-
filterRender(
) → Widget - Renders the filter UI above the list.
-
handlePageRequest(
int pageKey) → Future< void> - Handles pagination requests by fetching data for the specified page.
-
initState(
) → void -
Called when this object is inserted into the tree.
override
-
itemRender(
BuildContext context, T item, int index) → Widget - Renders a single list item.
-
noItemsFoundIndicatorBuilder(
BuildContext context) → Widget - Builds the indicator shown when no items are found.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCreate(
) → FutureOr< void> - Handler called when the create button is pressed.
-
onIndexChange(
) → void - Handler called when the list index changes.
-
onSearch(
String query) → void - Handles search query input and refreshes the list.
-
reassemble(
) → void -
Called whenever the application is reassembled during debugging, for
example during hot reload.
inherited
-
refresh(
) → Future< void> - Refreshes the list by resetting to the first page and reloading data.
-
reloadUI(
) → void - Forces a UI rebuild by calling setState.
-
reset(
) → Future< void> - Resets the list to the first page and clears all loaded items.
-
setState(
VoidCallback fn) → void -
Notify the framework that the internal state of this object has changed.
inherited
-
showFilterForm(
) → Future< void> - Shows the filter form dialog or bottom sheet.
-
showSearchBar(
) → void - Activates the search bar by setting isSearching to true.
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toggleSearch(
) → void - Toggles the search bar visibility.
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited