SortOrderCollection<T> class
A collection of sort orders with a selected active order.
This class manages multiple sorting options and tracks which one is currently active.
Example:
final orders = SortOrderCollection<Product>(
orders: [
SortOrder.byField(
id: 'name',
label: 'Name',
fieldSelector: (p) => p.name,
),
SortOrder.byField(
id: 'price',
label: 'Price',
fieldSelector: (p) => p.price,
),
],
defaultOrderId: 'name',
);
Constructors
-
SortOrderCollection({required List<
SortOrder< orders, String? defaultOrderId})T> > - Creates a collection of sort orders.
Properties
-
activeOrder
→ SortOrder<
T> ? -
Returns the currently active sort order, or null if none is active.
no setter
- activeOrderId → String?
-
Returns the ID of the currently active sort order.
no setter
-
defaultOrder
→ SortOrder<
T> ? -
Returns the default sort order, or null if none is set.
no setter
- defaultOrderId → String?
-
Returns the ID of the default sort order.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
orders
→ List<
SortOrder< T> > -
Returns all available sort orders.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addOrder(
SortOrder< T> order) → void - Adds a new sort order to the collection.
-
clearActiveOrder(
) → void - Clears the active sort order (no sorting will be applied).
-
copyWith(
{String? activeOrderId}) → SortOrderCollection< T> - Creates a copy of this collection with updated active order.
-
getOrder(
String orderId) → SortOrder< T> ? - Gets a sort order by ID.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeOrder(
String orderId) → bool - Removes a sort order by ID.
-
resetToDefault(
) → void - Resets to the default sort order.
-
setActiveOrder(
String orderId) → bool - Sets the active sort order by ID.
-
sortItems(
List< T> items) → List<T> - Sorts items using the active sort order.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited