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
Available extensions

Constructors

ReactiveSet(Set<T> value)
Creates a ReactiveSet with the given initial value.

Properties

canRedo bool
Returns true if redo is available.
no setterinherited
canUndo bool
Returns true if undo is available.
no setterinherited
first → T
The first element.
no setterinherited
firstOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The first element of this iterator, or null if the iterable is empty.
no setter
hashCode int
The hash code for this object.
no setterinherited
indexed Iterable<(int, T)>

Available on Iterable<T>, provided by the IterableExtensions extension

Pairs of elements of the indices and elements of this iterable.
no 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<T>, provided by the IterableExtensions extension

The last element of this iterable, or null if 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<T?>, provided by the NullableIterableExtensions extension

The non-null elements 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<T>, provided by the IterableExtensions extension

The single element of this iterator, or null.
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<Future<T>>, provided by the FutureIterable extension

Waits for futures in parallel.
no setter

Methods

add(T value) bool
Adds value to the set.
override
addAll(Iterable<T> elements) → void
Adds all elements to the set.
override
addListener(void listener(Set<T> value), {String? listenerName}) → void
Registers a listener that 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<T>, provided by the EnumByName extension

Creates a map from the names of enum values to the values.
bindStream(Stream<Set<T>> stream) StreamSubscription<Set<T>>
Binds a stream to this reactive variable.
inherited
byName(String name) → T

Available on Iterable<T>, provided by the EnumByName extension

Finds the enum value in this list with name name.
cast<R>() Set<R>
Provides a view of this set as a set of R instances.
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 true if element is 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<T>, provided by the IterableExtensions extension

The element at position index of this iterable, or null.
ever(void callback(Set<T> value)) → void
Registers a callback that 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 action on 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, or null.
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 callback that 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 value from the set.
override
removeAll(Iterable<Object?> elements) → void
Removes each element of elements from 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 count elements.
inherited
skipWhile(bool test(T value)) Iterable<T>
Creates an Iterable that skips leading elements while test is satisfied.
inherited
take(int n) Iterable<T>
Creates a lazy iterable of the count first 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