TransitionDelegate<T> class Null safety

The delegate that decides how pages added and removed from Navigator.pages transition in or out of the screen.

This abstract class implements the API to be called by Navigator when it requires explicit decisions on how the routes transition on or off the screen.

To make route transition decisions, subclass must implement resolve.

The following example demonstrates how to implement a subclass that always removes or adds routes without animated transitions and puts the removed routes at the top of the list.
class NoAnimationTransitionDelegate extends TransitionDelegate<void> {
  @override
  Iterable<RouteTransitionRecord> resolve({
    required List<RouteTransitionRecord> newPageRouteHistory,
    required Map<RouteTransitionRecord?, RouteTransitionRecord> locationToExitingPageRoute,
    required Map<RouteTransitionRecord?, List<RouteTransitionRecord>> pageRouteToPagelessRoutes,
  }) {
    final List<RouteTransitionRecord> results = <RouteTransitionRecord>[];

    for (final RouteTransitionRecord pageRoute in newPageRouteHistory) {
      if (pageRoute.isWaitingForEnteringDecision) {
        pageRoute.markForAdd();
      }
      results.add(pageRoute);

    }
    for (final RouteTransitionRecord exitingPageRoute in locationToExitingPageRoute.values) {
      if (exitingPageRoute.isWaitingForExitingDecision) {
       exitingPageRoute.markForRemove();
       final List<RouteTransitionRecord>? pagelessRoutes = pageRouteToPagelessRoutes[exitingPageRoute];
       if (pagelessRoutes != null) {
         for (final RouteTransitionRecord pagelessRoute in pagelessRoutes) {
            pagelessRoute.markForRemove();
          }
       }
      }
      results.add(exitingPageRoute);

    }
    return results;
  }
}

See also:

Implementers

Constructors

TransitionDelegate()
Creates a delegate and enables subclass to create a constant class.
const

Properties

hashCode int
The hash code for this object.
read-onlyinherited
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
resolve({required List<RouteTransitionRecord> newPageRouteHistory, required Map<RouteTransitionRecord?, RouteTransitionRecord> locationToExitingPageRoute, required Map<RouteTransitionRecord?, List<RouteTransitionRecord>> pageRouteToPagelessRoutes}) Iterable<RouteTransitionRecord>
A method that will be called by the Navigator to decide how routes transition in or out of the screen when Navigator.pages is updated.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited