Visitar URL original
RouteAware.didPushNext documentation is incorrect · Issue #24594 · flutter/flutter · GitHub
Skip to content

RouteAware.didPushNext documentation is incorrect #24594

Closed

Description

@alanrussian

Internal: b/292548580

"Called when a new route has been pushed, and the current route is no longer visible."

It's called before the route transition is finished; therefore, the current route is still visible, just obscured. This is an important distinction in some scenarios like one I ran into today where I wanted to do something as soon as the route containing the current widget was no longer visible whatsoever.

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: routesNavigator, Router, and related APIs.
    on Nov 21, 2018
  2. added this to the milestone on Nov 21, 2018
  3. added
    P2Important issues not at the top of the work list
    on May 29, 2020
  4. removed this from the milestone on Aug 17, 2020
  5. ishaquehassan commented on Mar 1, 2026

    @ishaquehassan
    Contributor

    After tracing through the source code in routes.dart, I can confirm the documentation is indeed inaccurate.

    In RouteObserver.didPush() (around line 2506), routeAware.didPushNext() is called synchronously during the push operation, before the route transition animation completes. At this point, the current route is still partially visible (being animated away), not "no longer visible" as the documentation states.

    The current documentation:

    /// Called when a new route has been pushed, and the current route is no
    /// longer visible.
    void didPushNext() {}

    Suggested fix:

    /// Called when a new route has been pushed.
    ///
    /// 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.
    void didPushNext() {}

    This clarifies the exact timing and provides guidance for developers who need to act after the route is fully hidden.

  6. added a commit that references this issue on Mar 1, 2026
    7c1e2e0
  7. github-actions commented on Mar 28, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listcustomer: mulligan (g3)d: api docsIssues with https://api.flutter.dev/f: routesNavigator, Router, and related APIs.frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions