NotifiableSet<E> class
Null safety
Class that mimics Set, and notify its listener every time the set is changed.
This set will notify its listener when a change is detected (an item has been added, removed, updated, etc... or the set has been sorted, mapped, etc...). However, it won't notify its listener if its items are changed, even if they extends ChangeNotifier.
- Inheritance
- Object
- ChangeNotifier
- NotifiableSet
- Available Extensions
Constructors
- NotifiableSet({dynamic propagateNotification = true})
- Create an empty NotifiableSet. [...]
- NotifiableSet.from(Iterable elements, {dynamic propagateNotification = true})
-
Create a NotifiableSet by adding all elements from
elements, regardless of their type. [...] -
NotifiableSet.of(Iterable<
E> elements, {dynamic propagateNotification = true}) -
Create a NotifiableSet by adding all elements of
elementsof typeE. [...]
Properties
- first → E
-
Returns the first element. [...]
read-only
- hashCode → int
-
The hash code for this object. [...]
read-only
- hasListeners → bool
-
Whether any listeners are currently registered. [...]
@protected, read-only, inherited
- isEmpty → bool
-
Returns
trueif there are no elements in this collection. [...]read-only - isNotEmpty → bool
-
Returns true if there is at least one element in this collection. [...]
read-only
-
iterator
→ Iterator<
E> -
An iterator that iterates over the elements of this set. [...]
read-only
- last → E
-
Returns the last element. [...]
read-only
- length → int
-
Returns the number of elements in the iterable. [...]
read-only
- propagateNotification ↔ bool
-
The boolean that indicates if the notification from its children should
propagate. [...]
read / write
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- single → E
-
Checks that this iterable has only one element, and returns that element. [...]
read-only
Methods
-
add(
E element) → bool -
Adds
valueto the set. [...] -
addAll(
Iterable< E> elements) → void -
Adds all
elementsto this set. [...] -
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes. [...]
inherited
-
any(
bool test(E element)) → bool -
Checks whether any element of this iterable satisfies
test. [...] -
asMap(
) → Map< int, E> -
Return a
Mapwhere the keys are the indices and the values the elements of this set. -
asNotifiableMap(
) → NotifiableMap< int, E> - Return a NotifiableMap where the keys are the indices and the values the elements of this set.
-
cast<
R> () → Set< R> -
Provides a view of this set as a set of
Rinstances. [...] -
clear(
) → void - Removes all elements from the set.
-
contains(
Object? E) → bool -
Whether
valueis in the set. -
containsAll(
Iterable< Object?> other) → bool -
Whether this set contains all the elements of
other. -
difference(
Set< Object?> other) → NotifiableSet<E> -
Creates a new set with the elements of this that are not in
other. [...] -
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener and removeListener will throw after the object is
disposed). [...]
@mustCallSuper, inherited
-
elementAt(
int index) → E -
Returns the
indexth element. [...] -
every(
bool test(E element)) → bool -
Checks whether every element of this iterable satisfies
test. [...] -
expand<
T> (Iterable< T> f(E element)) → Iterable<T> -
Expands each element of this
Iterableinto zero or more elements. [...] -
firstWhere(
bool test(E element), {E orElse()?}) → E -
Returns the first element that satisfies the given predicate
test. [...] -
fold<
T> (T initialValue, T combine(T previousValue, E element)) → T - Reduces a collection to a single value by iteratively combining each element of the collection with an existing value [...]
-
followedBy(
Iterable< E> other) → Iterable<E> -
Returns the lazy concatenation of this iterable and
other. [...] -
forEach(
void f(E element)) → void -
Invokes
actionon each element of this iterable in iteration order. -
indexOf(
E element, [int start = 0]) → int -
Search for
elementstarting fromstartand return its index. [...] -
indexWhere(
bool test(E element), [int start = 0]) → int -
Iterate over the set and return the first element matching
test. [...] -
insert(
int index, E element) → bool -
Insert
elementin the set atindex. [...] -
intersection(
Set< Object?> other) → NotifiableSet<E> -
Creates a new set which is the intersection between this set and
other. [...] -
join(
[String separator = ""]) → String -
Converts each element to a
Stringand concatenates the strings. [...] -
lastWhere(
bool test(E element), {E orElse()?}) → E -
Returns the last element that satisfies the given predicate
test. [...] -
lookup(
Object? object) → E? -
If an object equal to
objectis in the set, return it. [...] -
map<
T> (T f(E e)) → Iterable< T> -
The current elements of this iterable modified by
toElement. [...] -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
notifyListeners(
) → void -
Call all the registered listeners. [...]
@protected, @visibleForTesting, inherited
-
reduce(
E combine(E value, E element)) → E - Reduces a collection to a single value by iteratively combining elements of the collection using the provided function. [...]
-
remove(
Object? E) → bool -
Removes
valuefrom the set. [...] -
removeAll(
Iterable< Object?> elements) → void -
Removes each element of
elementsfrom this set. -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes. [...]
inherited
-
removeWhere(
bool test(E element)) → void -
Removes all elements of this set that satisfy
test. -
replace(
E oldValue, E newValue) → void -
Replace the
oldValuewithnewValueif found. [...] -
retainAll(
Iterable< Object?> elements) → void -
Removes all elements of this set that are not elements in
elements. [...] -
retainWhere(
bool test(E element)) → void -
Removes all elements of this set that fail to satisfy
test. -
singleWhere(
bool test(E element), {E orElse()?}) → E -
Returns the single element that satisfies
test. [...] -
skip(
int count) → Iterable< E> -
Returns an
Iterablethat provides all but the firstcountelements. [...] -
skipWhile(
bool test(E value)) → Iterable< E> -
Returns an
Iterablethat skips leading elements whiletestis satisfied. [...] -
take(
int count) → Iterable< E> -
Returns a lazy iterable of the
countfirst elements of this iterable. [...] -
takeWhile(
bool test(E value)) → Iterable< E> -
Returns a lazy iterable of the leading elements satisfying
test. [...] -
toList(
{bool growable = true}) → List< E> -
Creates a
Listcontaining the elements of thisIterable. [...] -
toNotifiableList(
{bool growable = true}) → NotifiableList< E> - Create a NotifiableList containing the same elements as this set.
-
toNotifiableSet(
) → NotifiableSet< E> - Creates a NotifiableSet containing the same elements as this set.
-
toSet(
) → Set< E> -
Creates a
Setwith the same elements and behavior as thisSet. [...] -
toString(
) → String -
A string representation of this object. [...]
inherited
-
union(
Set< E> other) → NotifiableSet<E> -
Creates a new set which contains all the elements of this set and
other. [...] -
update(
int index, E newValue) → E -
Set the element at
indextonewValue. [...] -
where(
bool test(E element)) → Iterable< E> -
Returns a new lazy
Iterablewith all elements that satisfy the predicatetest. [...] -
whereType<
T> () → Iterable< T> -
Returns a new lazy
Iterablewith all elements that have typeT. [...]
Operators
-
operator +(
Iterable< E> other) → NotifiableSet<E> -
Creates a new NotifiableSet that contains the elements of this set and the elements of
otherin that order. -
operator ==(
Object other) → bool - The equality operator. [...]
-
operator [](
int index) → E -
Returns the element at
index. -
operator []=(
int index, E value) → void -
Update the element at
indexwith the new valuevalue.