ComparableWrapper<T> class
Wraps a value in a Comparable interface with a specified comparison function.
For example, this can be used to combine SortWithKeyExtension.sortWithKey and compareIterables:
class Name {
String surname;
String givenName;
Name(this.surname, this.givenName);
}
void main() {
var names = [
Name('Smith', 'Jane'),
Name('Doe', 'John'),
Name('Doe', 'Jane'),
Name('Galt', 'John'),
];
names.sortWithKey(
(name) => ComparableWrapper(
[name.surname, name.givenName],
compareIterables,
),
);
}
- Implemented types
Constructors
-
ComparableWrapper(T value, Comparator<
T> compare) - Constructor.
Properties
-
compare
→ Comparator<
T> -
The comparison function used to compare value to another
T
instance.final - hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → T
-
The wrapped value to compare.
final
Methods
-
compareTo(
ComparableWrapper< T> other) → int -
Compares this object to another object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited