SharedAxisPageTransitionsBuilder class

Used by PageTransitionsTheme to define a page route transition animation in which outgoing and incoming elements share a fade transition.

The shared axis pattern provides the transition animation between UI elements that have a spatial or navigational relationship. For example, transitioning from one page of a sign up page to the next one.

The following example shows how the SharedAxisPageTransitionsBuilder can be used in a PageTransitionsTheme to change the default transitions of MaterialPageRoutes.

MaterialApp(
  theme: ThemeData(
    pageTransitionsTheme: PageTransitionsTheme(
      builders: {
        TargetPlatform.android: SharedAxisPageTransitionsBuilder(
          transitionType: SharedAxisTransitionType.horizontal,
        ),
        TargetPlatform.iOS: SharedAxisPageTransitionsBuilder(
          transitionType: SharedAxisTransitionType.horizontal,
        ),
      },
    ),
  ),
  routes: {
    '/': (BuildContext context) {
      return Container(
        color: Colors.red,
        child: Center(
          child: ElevatedButton(
            child: Text('Push route'),
            onPressed: () {
              Navigator.of(context).pushNamed('/a');
            },
          ),
        ),
      );
    },
    '/a' : (BuildContext context) {
      return Container(
        color: Colors.blue,
        child: Center(
          child: ElevatedButton(
            child: Text('Pop route'),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
        ),
      );
    },
  },
);
Inheritance

Constructors

SharedAxisPageTransitionsBuilder({required SharedAxisTransitionType transitionType, Color? fillColor})
Construct a SharedAxisPageTransitionsBuilder.
const

Properties

fillColor Color?
The color to use for the background color during the transition.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
transitionType SharedAxisTransitionType
Determines which SharedAxisTransitionType to build.
final

Methods

buildTransitions<T>(PageRoute<T>? route, BuildContext? context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) Widget
Wraps the child with one or more transition widgets which define how route arrives on and leaves the screen.
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