Visitar URL original
Fix RouteAware.didPushNext documentation inaccuracy by ishaquehassan · Pull Request #183097 · flutter/flutter · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: rephrase didPushNext doc to avoid taboo phrase 'Note that'
  • Loading branch information
ishaquehassan committed Mar 6, 2026
commit 825fb11c7b23e135dcb49c3c68b883482bd4a1b9
10 changes: 5 additions & 5 deletions packages/flutter/lib/src/widgets/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2527,11 +2527,11 @@ abstract mixin class RouteAware {

/// Called when a new route has been pushed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will mean didPush and didPushNext have the same API docs preview in RouteAware's documentation, can we somehow differentiate them in the opening line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Updated the opening line to "Called when a new route has been pushed on top of this route, temporarily obscuring it." which better captures the semantics and distinguishes it from didPush.

///
/// Note that this is called during the push operation, before the transition
/// animation completes. At this point the current route may still be
/// partially visible as it animates out. To perform actions after the route
/// is fully obscured, consider using [ModalRoute.animation] to listen for
/// animation completion, for example:
/// This method is called synchronously during the push operation, before the
/// transition animation completes. The current route may still be partially
/// visible as it animates out. To perform actions after the route is fully
/// obscured, consider using [ModalRoute.animation] to listen for animation
/// completion, for example:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the route is fully obscured, wouldn't ModalRoute.animation be completed? Should we listen for the secondaryAnimation instead? Asking for clarification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! ModalRoute.animation is the route's own entrance animation, which is already completed by the time didPushNext fires. The correct one is secondaryAnimation, which is driven by the incoming route and goes from 0 to 1 as the new route transitions in. Updated the snippet to use secondaryAnimation instead.

///
/// ```dart
Comment thread
ishaquehassan marked this conversation as resolved.
Resolved
/// ModalRoute.of(context)?.animation?.addStatusListener((AnimationStatus status) {
Expand Down