TransitionDelegate<T> class

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.
import 'package:flutter/widgets.dart';

// ...

class NoAnimationTransitionDelegate extends TransitionDelegate<void> {
  @override
  Iterable<RouteTransitionRecord> resolve({
    List<RouteTransitionRecord> newPageRouteHistory,
    Map<RouteTransitionRecord, RouteTransitionRecord> locationToExitingPageRoute,
    Map<RouteTransitionRecord, List<RouteTransitionRecord>> pageRouteToPagelessRoutes,
  }) {
    final List<RouteTransitionRecord> results = <RouteTransitionRecord>[];

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

    }
    for (final RouteTransitionRecord exitingPageRoute in locationToExitingPageRoute.values) {
      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-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

resolve({List<RouteTransitionRecord> newPageRouteHistory, Map<RouteTransitionRecord, RouteTransitionRecord> locationToExitingPageRoute, 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. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited