Appearance
AttributeClassSet
class AttributeClassSet extends CssClassSetImpl implements CssClassSetInheritance
Object → SetBase<E> → AttributeClassSet
Implemented types
Constructors
AttributeClassSet()
AttributeClassSet(Element _element)Implementation
dart
AttributeClassSet(this._element);Properties
first no setter inherited
String get firstInherited from CssClassSetImpl.
Implementation
dart
String get first => readClasses().first;frozen no setter inherited
bool get frozenInherited from CssClassSetImpl.
Implementation
dart
bool get frozen => false;hashCode no setter inherited
int get hashCodeThe hash code for this object.
A hash code is a single integer which represents the state of the object that affects operator == comparisons.
All objects have hash codes. The default hash code implemented by Object represents only the identity of the object, the same way as the default operator == implementation only considers objects equal if they are identical (see identityHashCode).
If operator == is overridden to use the object state instead, the hash code must also be changed to represent that state, otherwise the object cannot be used in hash based data structures like the default Set and Map implementations.
Hash codes must be the same for objects that are equal to each other according to operator ==. The hash code of an object should only change if the object changes in a way that affects equality. There are no further requirements for the hash codes. They need not be consistent between executions of the same program and there are no distribution guarantees.
Objects that are not equal are allowed to have the same hash code. It is even technically allowed that all instances have the same hash code, but if clashes happen too often, it may reduce the efficiency of hash-based data structures like HashSet or HashMap.
If a subclass overrides hashCode, it should override the operator == operator as well to maintain consistency.
Inherited from Object.
Implementation
dart
external int get hashCode;isEmpty no setter inherited
bool get isEmptyInherited from CssClassSetImpl.
Implementation
dart
bool get isEmpty => readClasses().isEmpty;isNotEmpty no setter inherited
bool get isNotEmptyInherited from CssClassSetImpl.
Implementation
dart
bool get isNotEmpty => readClasses().isNotEmpty;iterator no setter inherited
Inherited from CssClassSetImpl.
Implementation
dart
Iterator<String> get iterator => readClasses().iterator;last no setter inherited
String get lastInherited from CssClassSetImpl.
Implementation
dart
String get last => readClasses().last;length no setter inherited
int get lengthInherited from CssClassSetImpl.
Implementation
dart
int get length => readClasses().length;runtimeType no setter inherited
Type get runtimeTypeA representation of the runtime type of the object.
Inherited from Object.
Implementation
dart
external Type get runtimeType;single no setter inherited
String get singleInherited from CssClassSetImpl.
Implementation
dart
String get single => readClasses().single;Methods
add() inherited
Add the class value to element.
This is the Dart equivalent of jQuery's addClass.
Inherited from CssClassSetImpl.
Implementation
dart
bool add(String value) {
_validateToken(value);
// TODO - figure out if we need to do any validation here
// or if the browser natively does enough.
return modify((s) => s.add(value)) ?? false;
}addAll() inherited
Add all classes specified in iterable to element.
This is the Dart equivalent of jQuery's addClass.
Inherited from CssClassSetImpl.
Implementation
dart
void addAll(Iterable<String> iterable) {
// TODO - see comment above about validation.
modify((s) => s.addAll(iterable.map(_validateToken)));
}any() inherited
Checks whether any element of this iterable satisfies test.
Checks every element in iteration order, and returns true if any of them make test return true, otherwise returns false. Returns false if the iterable is empty.
Example:
dart
final numbers = <int>[1, 2, 3, 5, 6, 7];
var result = numbers.any((element) => element >= 5); // true;
result = numbers.any((element) => element >= 10); // false;Inherited from CssClassSetImpl.
Implementation
dart
bool any(bool f(String element)) => readClasses().any(f);cast() inherited
Set<R> cast<R>()Provides a view of this set as a set of R instances.
If this set contains only instances of R, all read operations will work correctly. If any operation tries to access an element that is not an instance of R, the access will throw instead.
Elements added to the set (e.g., by using add or addAll) must be instances of R to be valid arguments to the adding function, and they must be instances of E as well to be accepted by this set as well.
Methods which accept one or more Object? as argument, like contains, remove and removeAll, will pass the argument directly to the this set's method without any checks. That means that you can do setOfStrings.cast<int>().remove("a") successfully, even if it looks like it shouldn't have any effect.
Inherited from SetBase.
Implementation
dart
Set<R> cast<R>() => Set.castFrom<E, R>(this);clear() inherited
void clear()Removes all elements from the set.
dart
final characters = <String>{'A', 'B', 'C'};
characters.clear(); // {}Inherited from CssClassSetImpl.
Implementation
dart
void clear() {
// TODO(sra): Do this without reading the classes.
modify((s) => s.clear());
}contains() inherited
Determine if this element contains the class value.
This is the Dart equivalent of jQuery's hasClass.
Inherited from CssClassSetImpl.
Implementation
dart
bool contains(Object? value) {
if (value is! String) return false;
_validateToken(value);
return readClasses().contains(value);
}containsAll() inherited
Whether this set contains all the elements of other.
dart
final characters = <String>{'A', 'B', 'C'};
final containsAB = characters.containsAll({'A', 'B'});
print(containsAB); // true
final containsAD = characters.containsAll({'A', 'D'});
print(containsAD); // falseInherited from CssClassSetImpl.
Implementation
dart
bool containsAll(Iterable<Object?> collection) =>
readClasses().containsAll(collection);difference() inherited
Creates a new set with the elements of this that are not in other.
That is, the returned set contains all the elements of this Set that are not elements of other according to other.contains.
dart
final characters1 = <String>{'A', 'B', 'C'};
final characters2 = <String>{'A', 'E', 'F'};
final differenceSet1 = characters1.difference(characters2);
print(differenceSet1); // {B, C}
final differenceSet2 = characters2.difference(characters1);
print(differenceSet2); // {E, F}Inherited from CssClassSetImpl.
Implementation
dart
Set<String> difference(Set<Object?> other) => readClasses().difference(other);elementAt() inherited
Returns the indexth element.
The index must be non-negative and less than length. Index zero represents the first element (so iterable.elementAt(0) is equivalent to iterable.first).
May iterate through the elements in iteration order, ignoring the first index elements and then returning the next. Some iterables may have a more efficient way to find the element.
Example:
dart
final numbers = <int>[1, 2, 3, 5, 6, 7];
final elementAt = numbers.elementAt(4); // 6Inherited from CssClassSetImpl.
Implementation
dart
String elementAt(int index) => readClasses().elementAt(index);every() inherited
Checks whether every element of this iterable satisfies test.
Checks every element in iteration order, and returns false if any of them make test return false, otherwise returns true. Returns true if the iterable is empty.
Example:
dart
final planetsByMass = <double, String>{0.06: 'Mercury', 0.81: 'Venus',
0.11: 'Mars'};
// Checks whether all keys are smaller than 1.
final every = planetsByMass.keys.every((key) => key < 1.0); // trueInherited from CssClassSetImpl.
Implementation
dart
bool every(bool f(String element)) => readClasses().every(f);expand() inherited
Expands each element of this Iterable into zero or more elements.
The resulting Iterable runs through the elements returned by toElements for each element of this, in iteration order.
The returned Iterable is lazy, and calls toElements for each element of this iterable every time the returned iterable is iterated.
Example:
dart
Iterable<int> count(int n) sync* {
for (var i = 1; i <= n; i++) {
yield i;
}
}
var numbers = [1, 3, 0, 2];
print(numbers.expand(count)); // (1, 1, 2, 3, 1, 2)Equivalent to:
dart
Iterable<T> expand<T>(Iterable<T> toElements(E e)) sync* {
for (var value in this) {
yield* toElements(value);
}
}Inherited from CssClassSetImpl.
Implementation
dart
Iterable<T> expand<T>(Iterable<T> f(String element)) =>
readClasses().expand<T>(f);firstWhere() inherited
The first element that satisfies the given predicate test.
Iterates through elements and returns the first to satisfy test.
Example:
dart
final numbers = <int>[1, 2, 3, 5, 6, 7];
var result = numbers.firstWhere((element) => element < 5); // 1
result = numbers.firstWhere((element) => element > 5); // 6
result =
numbers.firstWhere((element) => element > 10, orElse: () => -1); // -1If no element satisfies test, the result of invoking the orElse function is returned. If orElse is omitted, it defaults to throwing a StateError. Stops iterating on the first matching element.
Inherited from CssClassSetImpl.
Implementation
dart
String firstWhere(bool test(String value), {String orElse()?}) =>
readClasses().firstWhere(test, orElse: orElse);fold() inherited
T fold<T>(T initialValue, T Function(T previousValue, String element) combine)Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
Uses initialValue as the initial value, then iterates through the elements and updates the value with each element using the combine function, as if by:
dart
var value = initialValue;
for (E element in this) {
value = combine(value, element);
}
return value;Example of calculating the sum of an iterable:
dart
final numbers = <double>[10, 2, 5, 0.5];
const initialValue = 100.0;
final result = numbers.fold<double>(
initialValue, (previousValue, element) => previousValue + element);
print(result); // 117.5Inherited from CssClassSetImpl.
Implementation
dart
T fold<T>(T initialValue, T combine(T previousValue, String element)) {
return readClasses().fold<T>(initialValue, combine);
}followedBy() inherited
Creates the lazy concatenation of this iterable and other.
The returned iterable will provide the same elements as this iterable, and, after that, the elements of other, in the same order as in the original iterables.
Example:
dart
var planets = <String>['Earth', 'Jupiter'];
var updated = planets.followedBy(['Mars', 'Venus']);
print(updated); // (Earth, Jupiter, Mars, Venus)Inherited from SetBase.
Implementation
dart
Iterable<E> followedBy(Iterable<E> other) =>
FollowedByIterable<E>.firstEfficient(this, other);forEach() inherited
void forEach(void Function(String text) f)Invokes action on each element of this iterable in iteration order.
Example:
dart
final numbers = <int>[1, 2, 6, 7];
numbers.forEach(print);
// 1
// 2
// 6
// 7Inherited from CssClassSetImpl.
Implementation
dart
void forEach(void f(String element)) {
readClasses().forEach(f);
}intersection() inherited
Creates a new set which is the intersection between this set and other.
That is, the returned set contains all the elements of this Set that are also elements of other according to other.contains.
dart
final characters1 = <String>{'A', 'B', 'C'};
final characters2 = <String>{'A', 'E', 'F'};
final intersectionSet = characters1.intersection(characters2);
print(intersectionSet); // {A}Inherited from CssClassSetImpl.
Implementation
dart
Set<String> intersection(Set<Object?> other) =>
readClasses().intersection(other);join() inherited
Converts each element to a String and concatenates the strings.
Iterates through elements of this iterable, converts each one to a String by calling Object.toString, and then concatenates the strings, with the separator string interleaved between the elements.
Example:
dart
final planetsByMass = <double, String>{0.06: 'Mercury', 0.81: 'Venus',
0.11: 'Mars'};
final joinedNames = planetsByMass.values.join('-'); // Mercury-Venus-MarsInherited from CssClassSetImpl.
Implementation
dart
String join([String separator = ""]) => readClasses().join(separator);lastWhere() inherited
The last element that satisfies the given predicate test.
An iterable that can access its elements directly may check its elements in any order (for example a list starts by checking the last element and then moves towards the start of the list). The default implementation iterates elements in iteration order, checks test(element) for each, and finally returns that last one that matched.
Example:
dart
final numbers = <int>[1, 2, 3, 5, 6, 7];
var result = numbers.lastWhere((element) => element < 5); // 3
result = numbers.lastWhere((element) => element > 5); // 7
result = numbers.lastWhere((element) => element > 10,
orElse: () => -1); // -1If no element satisfies test, the result of invoking the orElse function is returned. If orElse is omitted, it defaults to throwing a StateError.
Inherited from CssClassSetImpl.
Implementation
dart
String lastWhere(bool test(String value), {String orElse()?}) =>
readClasses().lastWhere(test, orElse: orElse);lookup() inherited
Lookup from the Set interface. Not interesting for a String set.
Inherited from CssClassSetImpl.
Implementation
dart
String? lookup(Object? value) => contains(value) ? value as String : null;map() inherited
The current elements of this iterable modified by toElement.
Returns a new lazy Iterable with elements that are created by calling toElement on each element of this Iterable in iteration order.
The returned iterable is lazy, so it won't iterate the elements of this iterable until it is itself iterated, and then it will apply toElement to create one element at a time. The converted elements are not cached. Iterating multiple times over the returned Iterable will invoke the supplied toElement function once per element for on each iteration.
Methods on the returned iterable are allowed to omit calling toElement on any element where the result isn't needed. For example, elementAt may call toElement only once.
Equivalent to:
dart
Iterable<T> map<T>(T toElement(E e)) sync* {
for (var value in this) {
yield toElement(value);
}
}Example:
dart
var products = jsonDecode('''
[
{"name": "Screwdriver", "price": 42.00},
{"name": "Wingnut", "price": 0.50}
]
''');
var values = products.map((product) => product['price'] as double);
var totalPrice = values.fold(0.0, (a, b) => a + b); // 42.5.Inherited from CssClassSetImpl.
Implementation
dart
Iterable<T> map<T>(T f(String e)) => readClasses().map<T>(f);modify() inherited
Helper method used to modify the set of css classes on this element.
f - callback with: s - a Set of all the css class name currently on this element.
After f returns, the modified set is written to the className property of this element.
Inherited from CssClassSetImpl.
Implementation
dart
modify(f(Set<String> s)) {
Set<String> s = readClasses();
var ret = f(s);
writeClasses(s);
return ret;
}noSuchMethod() inherited
dynamic noSuchMethod(Invocation invocation)Invoked when a nonexistent method or property is accessed.
A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:
dart
dynamic object = 1;
object.add(42); // Statically allowed, run-time errorThis invalid code will invoke the noSuchMethod method of the integer 1 with an Invocation representing the .add(42) call and arguments (which then throws).
Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.
A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:
dart
class MockList<T> implements List<T> {
noSuchMethod(Invocation invocation) {
log(invocation);
super.noSuchMethod(invocation); // Will throw.
}
}
void main() {
MockList().add(42);
}This code has no compile-time warnings or errors even though the MockList class has no concrete implementation of any of the List interface methods. Calls to List methods are forwarded to noSuchMethod, so this code will log an invocation similar to Invocation.method(#add, [42]) and then throw.
If a value is returned from noSuchMethod, it becomes the result of the original invocation. If the value is not of a type that can be returned by the original invocation, a type error occurs at the invocation.
The default behavior is to throw a NoSuchMethodError.
Inherited from Object.
Implementation
dart
@pragma("vm:entry-point")
@pragma("wasm:entry-point")
external dynamic noSuchMethod(Invocation invocation);readClasses()
Read the class names from the Element class property, and put them into a set (duplicates are discarded). This is intended to be overridden by specific implementations.
Implementation
dart
Set<String> readClasses() {
var classname = _element.attributes['class'];
if (classname is AnimatedString) {
classname = (classname as AnimatedString).baseVal;
}
Set<String> s = new LinkedHashSet<String>();
if (classname == null) {
return s;
}
for (String name in classname.split(' ')) {
String trimmed = name.trim();
if (!trimmed.isEmpty) {
s.add(trimmed);
}
}
return s;
}reduce() inherited
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
The iterable must have at least one element. If it has only one element, that element is returned.
Otherwise this method starts with the first element from the iterator, and then combines it with the remaining elements in iteration order, as if by:
dart
E value = iterable.first;
iterable.skip(1).forEach((element) {
value = combine(value, element);
});
return value;Example of calculating the sum of an iterable:
dart
final numbers = <double>[10, 2, 5, 0.5];
final result = numbers.reduce((value, element) => value + element);
print(result); // 17.5Consider using fold if the iterable can be empty.
Inherited from CssClassSetImpl.
Implementation
dart
String reduce(String combine(String value, String element)) {
return readClasses().reduce(combine);
}remove() inherited
Remove the class value from element, and return true on successful removal.
This is the Dart equivalent of jQuery's removeClass.
Inherited from CssClassSetImpl.
Implementation
dart
bool remove(Object? value) {
if (value is! String) return false;
_validateToken(value);
Set<String> s = readClasses();
bool result = s.remove(value);
writeClasses(s);
return result;
}removeAll() inherited
Remove all classes specified in iterable from element.
This is the Dart equivalent of jQuery's removeClass.
Inherited from CssClassSetImpl.
Implementation
dart
void removeAll(Iterable<Object?> iterable) {
modify((s) => s.removeAll(iterable));
}removeWhere() inherited
Removes all elements of this set that satisfy test.
dart
final characters = <String>{'A', 'B', 'C'};
characters.removeWhere((element) => element.startsWith('B'));
print(characters); // {A, C}Inherited from CssClassSetImpl.
Implementation
dart
void removeWhere(bool test(String name)) {
modify((s) => s.removeWhere(test));
}retainAll() inherited
Removes all elements of this set that are not elements in elements.
Checks for each element of elements whether there is an element in this set that is equal to it (according to this.contains), and if so, the equal element in this set is retained, and elements that are not equal to any element in elements are removed.
dart
final characters = <String>{'A', 'B', 'C'};
characters.retainAll({'A', 'B', 'X'});
print(characters); // {A, B}Inherited from CssClassSetImpl.
Implementation
dart
void retainAll(Iterable<Object?> iterable) {
modify((s) => s.retainAll(iterable));
}retainWhere() inherited
Removes all elements of this set that fail to satisfy test.
dart
final characters = <String>{'A', 'B', 'C'};
characters.retainWhere(
(element) => element.startsWith('B') || element.startsWith('C'));
print(characters); // {B, C}Inherited from CssClassSetImpl.
Implementation
dart
void retainWhere(bool test(String name)) {
modify((s) => s.retainWhere(test));
}singleWhere() inherited
The single element that satisfies test.
Checks elements to see if test(element) returns true. If exactly one element satisfies test, that element is returned. If more than one matching element is found, throws StateError. If no matching element is found, returns the result of orElse. If orElse is omitted, it defaults to throwing a StateError.
Example:
dart
final numbers = <int>[2, 2, 10];
var result = numbers.singleWhere((element) => element > 5); // 10When no matching element is found, the result of calling orElse is returned instead.
dart
result = numbers.singleWhere((element) => element == 1,
orElse: () => -1); // -1There must not be more than one matching element.
dart
result = numbers.singleWhere((element) => element == 2); // Throws Error.Inherited from CssClassSetImpl.
Implementation
dart
String singleWhere(bool test(String value), {String orElse()?}) =>
readClasses().singleWhere(test, orElse: orElse);skip() inherited
Creates an Iterable that provides all but the first count elements.
When the returned iterable is iterated, it starts iterating over this, first skipping past the initial count elements. If this has fewer than count elements, then the resulting Iterable is empty. After that, the remaining elements are iterated in the same order as in this iterable.
Some iterables may be able to find later elements without first iterating through earlier elements, for example when iterating a List. Such iterables are allowed to ignore the initial skipped elements.
Example:
dart
final numbers = <int>[1, 2, 3, 5, 6, 7];
final result = numbers.skip(4); // (6, 7)
final skipAll = numbers.skip(100); // () - no elements.The count must not be negative.
Inherited from CssClassSetImpl.
Implementation
dart
Iterable<String> skip(int n) => readClasses().skip(n);skipWhile() inherited
Creates an Iterable that skips leading elements while test is satisfied.
The filtering happens lazily. Every new Iterator of the returned iterable iterates over all elements of this.
The returned iterable provides elements by iterating this iterable, but skipping over all initial elements where test(element) returns true. If all elements satisfy test the resulting iterable is empty, otherwise it iterates the remaining elements in their original order, starting with the first element for which test(element) returns false.
Example:
dart
final numbers = <int>[1, 2, 3, 5, 6, 7];
var result = numbers.skipWhile((x) => x < 5); // (5, 6, 7)
result = numbers.skipWhile((x) => x != 3); // (3, 5, 6, 7)
result = numbers.skipWhile((x) => x != 4); // ()
result = numbers.skipWhile((x) => x.isOdd); // (2, 3, 5, 6, 7)Inherited from CssClassSetImpl.
Implementation
dart
Iterable<String> skipWhile(bool test(String value)) =>
readClasses().skipWhile(test);take() inherited
Creates a lazy iterable of the count first elements of this iterable.
The returned Iterable may contain fewer than count elements, if this contains fewer than count elements.
The elements can be computed by stepping through iterator until count elements have been seen.
The count must not be negative.
Example:
dart
final numbers = <int>[1, 2, 3, 5, 6, 7];
final result = numbers.take(4); // (1, 2, 3, 5)
final takeAll = numbers.take(100); // (1, 2, 3, 5, 6, 7)Inherited from CssClassSetImpl.
Implementation
dart
Iterable<String> take(int n) => readClasses().take(n);takeWhile() inherited
Creates a lazy iterable of the leading elements satisfying test.
The filtering happens lazily. Every new iterator of the returned iterable starts iterating over the elements of this.
The elements can be computed by stepping through iterator until an element is found where test(element) is false. At that point, the returned iterable stops (its moveNext() returns false).
Example:
dart
final numbers = <int>[1, 2, 3, 5, 6, 7];
var result = numbers.takeWhile((x) => x < 5); // (1, 2, 3)
result = numbers.takeWhile((x) => x != 3); // (1, 2)
result = numbers.takeWhile((x) => x != 4); // (1, 2, 3, 5, 6, 7)
result = numbers.takeWhile((x) => x.isOdd); // (1)Inherited from CssClassSetImpl.
Implementation
dart
Iterable<String> takeWhile(bool test(String value)) =>
readClasses().takeWhile(test);toggle() inherited
Adds the class value to the element if it is not on it, removes it if it is.
If shouldAdd is true, then we always add that value to the element. If shouldAdd is false then we always remove value from the element.
Inherited from CssClassSetImpl.
Implementation
dart
bool toggle(String value, [bool? shouldAdd]) {
_validateToken(value);
Set<String> s = readClasses();
bool result = false;
if (shouldAdd == null) shouldAdd = !s.contains(value);
if (shouldAdd) {
s.add(value);
result = true;
} else {
s.remove(value);
}
writeClasses(s);
return result;
}toggleAll() inherited
Toggles all classes specified in iterable on element.
Iterate through iterable's items, and add it if it is not on it, or remove it if it is. This is the Dart equivalent of jQuery's toggleClass. If shouldAdd is true, then we always add all the classes in iterable element. If shouldAdd is false then we always remove all the classes in iterable from the element.
Inherited from CssClassSetImpl.
Implementation
dart
void toggleAll(Iterable<String> iterable, [bool? shouldAdd]) {
iterable.forEach((e) => toggle(e, shouldAdd));
}toList() inherited
Creates a List containing the elements of this Iterable.
The elements are in iteration order. The list is fixed-length if growable is false.
Example:
dart
final planets = <int, String>{1: 'Mercury', 2: 'Venus', 3: 'Mars'};
final keysList = planets.keys.toList(growable: false); // [1, 2, 3]
final valuesList =
planets.values.toList(growable: false); // [Mercury, Venus, Mars]Inherited from CssClassSetImpl.
Implementation
dart
List<String> toList({bool growable = true}) =>
readClasses().toList(growable: growable);toSet() inherited
Creates a Set with the same elements and behavior as this Set.
The returned set behaves the same as this set with regard to adding and removing elements. It initially contains the same elements. If this set specifies an ordering of the elements, the returned set will have the same order.
Inherited from CssClassSetImpl.
Implementation
dart
Set<String> toSet() => readClasses().toSet();toString() inherited
String toString()A string representation of this object.
Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.
Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.
Inherited from CssClassSetImpl.
Implementation
dart
String toString() {
return readClasses().join(' ');
}union() inherited
Creates a new set which contains all the elements of this set and other.
That is, the returned set contains all the elements of this Set and all the elements of other.
dart
final characters1 = <String>{'A', 'B', 'C'};
final characters2 = <String>{'A', 'E', 'F'};
final unionSet1 = characters1.union(characters2);
print(unionSet1); // {A, B, C, E, F}
final unionSet2 = characters2.union(characters1);
print(unionSet2); // {A, E, F, B, C}Inherited from CssClassSetImpl.
Implementation
dart
Set<String> union(Set<String> other) => readClasses().union(other);where() inherited
Creates a new lazy Iterable with all elements that satisfy the predicate test.
The matching elements have the same order in the returned iterable as they have in iterator.
This method returns a view of the mapped elements. As long as the returned Iterable is not iterated over, the supplied function test will not be invoked. Iterating will not cache results, and thus iterating multiple times over the returned Iterable may invoke the supplied function test multiple times on the same element.
Example:
dart
final numbers = <int>[1, 2, 3, 5, 6, 7];
var result = numbers.where((x) => x < 5); // (1, 2, 3)
result = numbers.where((x) => x > 5); // (6, 7)
result = numbers.where((x) => x.isEven); // (2, 6)Inherited from CssClassSetImpl.
Implementation
dart
Iterable<String> where(bool f(String element)) => readClasses().where(f);whereType() inherited
Iterable<T> whereType<T>()Creates a new lazy Iterable with all elements that have type T.
The matching elements have the same order in the returned iterable as they have in iterator.
This method returns a view of the mapped elements. Iterating will not cache results, and thus iterating multiple times over the returned Iterable may yield different results, if the underlying elements change between iterations.
Inherited from SetBase.
Implementation
dart
Iterable<T> whereType<T>() => WhereTypeIterable<T>(this);writeClasses()
void writeClasses(Set<dynamic> s)Join all the elements of a set into one string and write back to the element. This is intended to be overridden by specific implementations.
Implementation
dart
void writeClasses(Set s) {
_element.setAttribute('class', s.join(' '));
}Operators
operator ==() inherited
The equality operator.
The default behavior for all Objects is to return true if and only if this object and other are the same object.
Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:
Total: It must return a boolean for all arguments. It should never throw.
Reflexive: For all objects
o,o == omust be true.Symmetric: For all objects
o1ando2,o1 == o2ando2 == o1must either both be true, or both be false.Transitive: For all objects
o1,o2, ando3, ifo1 == o2ando2 == o3are true, theno1 == o3must be true.
The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.
If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.
Inherited from Object.
Implementation
dart
external bool operator ==(Object other);