ReactiveSet<T> class
A reactive set that automatically notifies listeners when modified.
ReactiveSet combines the functionality of Dart's Set with reactive state management. Any modification to the set (add, remove, etc.) automatically triggers UI updates in dependent Observer widgets.
All standard Set operations are supported, plus reactive features from Reactive like listeners, history tracking, and stream binding.
Example:
final tags = ReactiveSet<String>({'flutter', 'dart'});
// Use in Observer widget
Observer(
builder: (_) => Wrap(
children: tags.map((tag) => Chip(label: Text(tag))).toList(),
),
);
// Modifications trigger automatic UI updates
tags.add('mobile');
tags.remove('dart');
tags.addAll({'ios', 'android'});
- Inheritance
- Mixed-in types
-
- SetMixin<
T>
- SetMixin<
- Available extensions
Constructors
-
ReactiveSet(Set<
T> value) -
Creates a ReactiveSet with the given initial
value.
Properties
- canRedo → bool
-
Returns
trueif redo is available.no setterinherited - canUndo → bool
-
Returns
trueif undo is available.no setterinherited - first → T
-
The first element.
no setterinherited
- firstOrNull → T?
-
Available on Iterable<
The first element of this iterator, orT> , provided by the IterableExtensions extensionnullif the iterable is empty.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
-
indexed
→ Iterable<
(int, T)> -
Available on Iterable<
Pairs of elements of the indices and elements of this iterable.T> , provided by the IterableExtensions extensionno setter - isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ Iterator<
T> -
Returns an iterator for the set elements.
no setteroverride
- last → T
-
The last element.
no setterinherited
- lastOrNull → T?
-
Available on Iterable<
The last element of this iterable, orT> , provided by the IterableExtensions extensionnullif the iterable is empty.no setter - length → int
-
Returns the number of elements in the set.
no setteroverride
-
listeners
→ List<
Function> -
Returns a list of all registered listener functions.
no setterinherited
-
nonNulls
→ Iterable<
T> -
Available on Iterable<
The non-T?> , provided by the NullableIterableExtensions extensionnullelements of this iterable.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- single → T
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
- singleOrNull → T?
-
Available on Iterable<
The single element of this iterator, orT> , provided by the IterableExtensions extensionnull.no setter -
value
↔ Set<
T> -
Gets the current set value.
getter/setter pairinherited-setteroverride-getter
-
valueNotifier
→ ValueNotifier<
Set< T> > -
Provides access to the underlying ValueNotifier.
no setterinherited
-
wait
→ Future<
List< T> > -
Available on Iterable<
Waits for futures in parallel.Future< , provided by the FutureIterable extensionT> >no setter
Methods
-
add(
T value) → bool -
Adds
valueto the set.override -
addAll(
Iterable< T> elements) → void -
Adds all
elementsto the set.override -
addListener(
void listener(Set< T> value), {String? listenerName}) → void -
Registers a
listenerthat will be called whenever the value changes.inherited -
any(
bool test(T element)) → bool -
Checks whether any element of this iterable satisfies
test.inherited -
asNameMap(
) → Map< String, T> -
Available on Iterable<
Creates a map from the names of enum values to the values.T> , provided by the EnumByName extension -
bindStream(
Stream< Set< stream) → StreamSubscription<T> >Set< T> > -
Binds a
streamto this reactive variable.inherited -
byName(
String name) → T -
Available on Iterable<
Finds the enum value in this list with nameT> , provided by the EnumByName extensionname. -
cast<
R> () → Set< R> -
Provides a view of this set as a set of
Rinstances.inherited -
clear(
) → void -
Removes all elements from the set.
inherited
-
clearHistory(
) → void -
Clears all history and resets to the current value.
inherited
-
close(
) → void -
Disposes of all resources used by this reactive variable.
inherited
-
contains(
Object? element) → bool -
Returns
trueifelementis in the set.override -
containsAll(
Iterable< Object?> other) → bool -
Whether this set contains all the elements of
other.inherited -
difference(
Set< Object?> other) → Set<T> -
Creates a new set with the elements of this that are not in
other.inherited -
elementAt(
int index) → T -
Returns the
indexth element.inherited -
elementAtOrNull(
int index) → T? -
Available on Iterable<
The element at positionT> , provided by the IterableExtensions extensionindexof this iterable, ornull. -
ever(
void callback(Set< T> value)) → void -
Registers a
callbackthat executes every time the value changes.inherited -
every(
bool f(T element)) → bool -
Checks whether every element of this iterable satisfies
test.inherited -
expand<
T> (Iterable< T> f(T element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
firstWhere(
bool test(T value), {T orElse()?}) → T -
The first element that satisfies the given predicate
test.inherited -
fold<
T> (T initialValue, T combine(T previousValue, T element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< T> other) → Iterable<T> -
Creates the lazy concatenation of this iterable and
other.inherited -
forEach(
void f(T element)) → void -
Invokes
actionon each element of this iterable in iteration order.inherited -
intersection(
Set< Object?> other) → Set<T> -
Creates a new set which is the intersection between this set and
other.inherited -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastWhere(
bool test(T value), {T orElse()?}) → T -
The last element that satisfies the given predicate
test.inherited -
lookup(
Object? element) → T? -
Returns the element in the set that is equal to
element, ornull.override -
map<
T> (T f(T element)) → Iterable< T> -
The current elements of this iterable modified by
toElement.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
once(
void callback(Set< T> value)) → void -
Registers a
callbackthat executes only once on the next value change.inherited -
redo(
) → bool -
Reapplies a previously undone value.
inherited
-
reduce(
T combine(T value, T element)) → T -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
refresh(
) → void -
Manually triggers an update to all listeners and Observer widgets.
inherited
-
remove(
Object? value) → bool -
Removes
valuefrom the set.override -
removeAll(
Iterable< Object?> elements) → void -
Removes each element of
elementsfrom this set.inherited -
removeAllListeners(
) → void -
Removes all registered listeners from this reactive variable.
inherited
-
removeListener(
{required String listenerName}) → void -
Removes a specific listener by its
listenerName.inherited -
removeWhere(
bool test(T)) → void -
Removes all elements that satisfy
test.override -
retainAll(
Iterable< Object?> elements) → void -
Removes all elements of this set that are not elements in
elements.inherited -
retainWhere(
bool test(T element)) → void -
Removes all elements of this set that fail to satisfy
test.inherited -
setDebounce(
Duration duration) → void -
Configures debounce behavior for value updates.
inherited
-
setThrottle(
Duration duration) → void -
Configures throttle behavior for value updates.
inherited
-
singleWhere(
bool test(T value), {T orElse()?}) → T -
The single element that satisfies
test.inherited -
skip(
int n) → Iterable< T> -
Creates an Iterable that provides all but the first
countelements.inherited -
skipWhile(
bool test(T value)) → Iterable< T> -
Creates an
Iterablethat skips leading elements whiletestis satisfied.inherited -
take(
int n) → Iterable< T> -
Creates a lazy iterable of the
countfirst elements of this iterable.inherited -
takeWhile(
bool test(T value)) → Iterable< T> -
Creates a lazy iterable of the leading elements satisfying
test.inherited -
toList(
{bool growable = true}) → List< T> -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< T> -
Creates a Set containing the elements of this set.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
undo(
) → bool -
Reverts to the previous value in history.
inherited
-
union(
Set< T> other) → Set<T> -
Creates a new set which contains all the elements of this set and
other.inherited -
updateDebounced(
Set< T> value) → void -
Updates the value with debounce applied.
inherited
-
updateThrottled(
Set< T> value) → void -
Updates the value with throttle applied.
inherited
-
where(
bool f(T)) → Iterable< T> -
Returns a new lazy iterable with all elements that satisfy
f.override -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited