OrderComparator class abstract final

Sorts objects the way the framework does: PriorityOrdered first, then by order value, objects with equal values keeping their original order.

Use it when your own code holds a list of objects that should run in the same order the framework would use, such as plug-ins collected from beans. Dart reads no annotations at run time, so @Order values must be passed through the fallback callback (the container keeps them in the bean definitions).

final sorted = OrderComparator.sort(
  handlers,
  (handler) => handler is FirstHandler ? 1 : null,
);
final order = OrderComparator.orderOf(handler); // lowest if unordered

Spring (Java):

List<Handler> sorted = new ArrayList<>(handlers);
AnnotationAwareOrderComparator.sort(sorted);

Unlike Spring's OrderComparator, annotations are not read at run time (there is no reflection); pass their values through fallback.

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

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

Static Methods

orderOf(Object object, [int? fallback]) → int
The order of object: its Ordered.order when it implements Ordered, otherwise fallback, otherwise Ordered.lowestPrecedence.
sort<T extends Object>(Iterable<T> items, [int? fallback(T item)?]) → List<T>
Returns items as a new sorted list; items itself is not changed. Items with equal orders keep their original order.