A contract for objects that are assigned an order or precedence value.
This is typically used for sorting or prioritization where lower values have
higher priority (i.e., 0
is higher than 10
).
Framework components such as filters, interceptors, and plugins can implement Ordered to control execution sequence.
π§ Ordering Rules
- Lower values indicate higher priority
- Constants are provided for extreme values:
- Ordered.HIGHEST_PRECEDENCE =
-2^31
(highest possible priority) - Ordered.LOWEST_PRECEDENCE =
2^31 - 1
(lowest possible priority)
- Ordered.HIGHEST_PRECEDENCE =
π Example
class MyFilter implements Ordered {
@override
int get order => 10;
}
final filters = [MyFilter(), AnotherFilter()];
filters.sort((a, b) => a.order.compareTo(b.order));
- Implementers
Properties
- hashCode β int
-
The hash code for this object.
no setterinherited
- runtimeType β Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getOrder(
) β int - A contract for objects that are assigned an order or precedence value.
-
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
Constants
- HIGHEST_PRECEDENCE β const int
- The highest possible precedence value.
- LOWEST_PRECEDENCE β const int
- The lowest possible precedence value.