withTransition<T> static method

Future<T> withTransition<T>(
  1. Future<T> operation()
)

Wraps an async navigation operation with transition notifications.

Example:

await CNTransitionHelper.withTransition(() async {
  await Navigator.of(context).pushNamed('/details');
});

Implementation

static Future<T> withTransition<T>(Future<T> Function() operation) async {
  await beginTransition();
  try {
    return await operation();
  } finally {
    // Delay end to allow animation to complete
    Future.delayed(const Duration(milliseconds: 350), endTransition);
  }
}