transitionDuration property

Duration get transitionDuration

The total duration of the most recent page transition.

When called during a page transition, it will return the full duration of the currently active page transition. If called immediately after a call to Navigator.pop, for example, it will return the duration of the transition triggered by that call. If called halfway through a page transition, it will still return the full duration, not half.

To pump until the route transition is finished and the previous route is completely gone, use the following:

link
testWidgets('MyWidget', (WidgetTester tester) async {
  // ...Pump the app and start a page transition, then:
  await tester.pump();
  await tester.pump(transitionDurationObserver.transitionDuration + const Duration(milliseconds: 1));
});

Throws if there has never been a page transition.

See also:

Implementation

Duration get transitionDuration {
  if (_transitionDuration == null) {
    throw FlutterError(
      'No route transition has occurred, but the transition duration was requested.',
    );
  }
  return _transitionDuration!;
}