GroupedDataSource<PageKey, Parent, Value> class
abstract
An extension of DataSource that automatically groups its items into sections based on a developer-defined condition.
Use this class to power GroupedPagingList or GroupedPagingGrid. To use it,
you must extend it and implement the groupBy method, which defines how
items are categorized into groups.
The GroupedDataSource listens for changes to the underlying flat list of items from DataSource and re-computes the grouped structure on demand, caching the result for efficiency.
- Inheritance
-
- Object
- DataSource<
PageKey, Value> - GroupedDataSource
Constructors
-
GroupedDataSource({Set<
LoadErrorPolicy> errorPolicy = const {}}) - Creates a GroupedDataSource and sets up a listener to invalidate the group cache when the underlying data changes.
Properties
-
errorPolicy
↔ Set<
LoadErrorPolicy> -
Defines the error handling policy for load operations.
By default, all errors are shown in the UI.
getter/setter pairinherited
-
groupedValues
→ List<
GroupedPageData< Parent, Value> > -
Returns a cached, grouped list of data suitable for sectioned UI.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
notifier
→ PageManager<
PageKey, Value> -
The underlying state manager for the data source.
no setterinherited
-
onLoadFinished
↔ void Function(LoadAction<
PageKey> action, LoadResult<PageKey, Value> result)? -
A callback invoked after every
loadoperation completes, providing the LoadResult. Useful for analytics or showing temporary error messages.getter/setter pairinherited -
onLoadStarted
↔ void Function(LoadAction<
PageKey> action)? -
A callback that is invoked just before a
loadoperation begins. It provides the LoadAction that is about to be executed.getter/setter pairinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
VoidCallback listener) → void -
Registers a callback to be invoked when the data or loading state changes.
inherited
-
append(
) → Future< void> -
Triggers an append operation to load data after the current items.
inherited
-
dispose(
) → void -
Releases the resources used by this DataSource.
override
-
groupBy(
Value value) → Parent - Extracts the group identifier (the "parent") from a given item.
-
insertItem(
int index, Value item) → void -
Inserts an
itemat the specifiedindexand notifies listeners.inherited -
load(
LoadAction< PageKey> action) → Future<LoadResult< PageKey, Value> > -
Loads a page of data based on the specified LoadAction.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prepend(
) → Future< void> -
Triggers a prepend operation to load data before the current items.
inherited
-
refresh(
) → Future< void> -
Triggers a full refresh of the data, discarding the existing items.
inherited
-
removeItem(
int index) → void -
Removes a single item at the specified
indexand notifies listeners.inherited -
removeItems(
bool test(int index, Value item)) → void -
Removes all items that satisfy the given
testand notifies listeners.inherited -
removeListener(
VoidCallback listener) → void -
Removes a previously registered callback.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateItem(
int index, Value update(Value item)) → void -
Updates a single item in the list at the specified
index.inherited -
updateItems(
Value update(int index, Value item)) → void -
Updates all items currently in the list and notifies listeners.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited