CollectionSelection<K> class
final
Immutable key-based selection with explicit and all-matching representations.
allMatching represents a query-wide selection, not an enumeration of loaded items. The application must bind it to the intended query and handle query changes. Operations return a new selection; rebuild the consumer with that result.
- Annotations
Constructors
-
CollectionSelection.allMatching([Iterable<
K> excludedKeys = const []]) -
Selects the entire externally defined query except a defensive copy of
excludedKeys. This does not fetch or enumerate items.factory -
CollectionSelection.multiple([Iterable<
K> selectedKeys = const []]) -
Creates multi-selection state from a defensive, deduplicated copy of
selectedKeys.factory - CollectionSelection.none()
-
Creates a disabled selection; contains always returns false.
factory
- CollectionSelection.single([K? selectedKey])
-
Creates single-selection state, optionally selecting
selectedKey. A null key means no selection.factory
Properties
-
excludedKeys
→ Set<
K> -
Unmodifiable exceptions to query-wide selection in all-matching mode.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether explicit selection is empty. Always false for all-matching mode
because unloaded matching items may exist.
no setter
- isEnabled → bool
-
Whether the mode permits selection rather than disabling it.
no setter
- mode → CollectionSelectionMode
-
Policy controlling how selected and excluded keys are interpreted.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
selectedKeys
→ Set<
K> -
Unmodifiable explicit keys used by single and multiple modes. Empty in
all-matching mode.
final
Methods
-
clear(
) → CollectionSelection< K> - Removes selection. Disabled and explicit modes keep their policy; all-matching mode becomes an empty multiple selection rather than excluding an unknowable universe of keys.
-
contains(
K key) → bool -
Tests
keyaccording to mode. All-matching mode returns true unless the key is excluded; the caller is responsible for query membership. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
select(
K key) → CollectionSelection< K> -
Returns selection including
key. Single mode replaces the previous key; multiple mode adds it; all-matching mode removes its exclusion. Disabled mode is unchanged. -
selectLoaded(
Iterable< K> keys) → CollectionSelection<K> -
Includes the supplied loaded
keyswithout discarding selections outside that set. -
toggle(
K key) → CollectionSelection< K> - Returns unselect for an included key or select for an excluded key.
-
toString(
) → String -
A string representation of this object.
inherited
-
unselect(
K key) → CollectionSelection< K> -
Returns selection without
key. Single mode clears the selection; multiple mode removes the key; all-matching mode adds an exclusion. Disabled mode is unchanged. -
unselectLoaded(
Iterable< K> keys) → CollectionSelection<K> -
Excludes only the supplied loaded
keys, preserving unrelated explicit keys or all-matching exclusions. Single mode is cleared only when its selected key is supplied.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited