toggle method
Removes the value
from the set of the corresponding key
,
if it exists in the set. Otherwise, adds it to the set.
If the key
doesn't exist, it will be created and then have the new value
added to the new, corresponding set.
However, if can force the value
to be added or removed by providing
state
true or false.
Implementation
@useCopy
IMapOfSets<K, V> toggle(K key, V value, {bool? state}) =>
(state ?? !contains(key, value)) ? add(key, value) : remove(key, value);