Skip to content

Proposal: [go_router_builder] Allow users to specify onExit as optional #183099

Open

Description

@hantrungkien

Use Case

I'm using go_router_builder and have three routes

HomeRouteData, Details1RouteData, and Details2RouteData, corresponding to HomePage, Details1Page, and Details2Page.

On HomePage, I push Details1Page and wait for a returned result. here
On Details1Page, I push Details2Page and wait for a result. here
On Details2Page, I pop to return to Details1Page. here
At that point, I continue to pop to go back to HomePage from Details1Page, but I can’t. here

After investigating the root cause, I found that the issue is due to the onExit callback always being passed into the GoRoute constructor.

Proposal

Option 1:

Use a variable similar to caseSensitive to determine whether this route implements the onExit callback.

  const TypedGoRoute({
    required this.path,
    this.name,
    this.routes = const <TypedRoute<RouteData>>[],
    this.caseSensitive = true,
    this.overrideOnExit = false,
  });

Option 2:

Check whether the child route actually overrides the onExit function at the time build_runner runs: go_router_builder

        final bool hasOverriddenOnExit = classElement.methods.any(
          (method) => method.name == 'onExit',
        );

Activity

  1. added
    in triagePresently being triaged by the triage team
    c: proposalA detailed proposal for a change to Flutter
    packageflutter/packages repository. See also p: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Mar 4, 2026
  2. changed the title [-][go_router_builder] Allow users to specify onExit as optional[/-] [+]Proposal: [go_router_builder] Allow users to specify onExit as optional[/+] on Mar 4, 2026
  3. added
    P2Important issues not at the top of the work list
    on Mar 10, 2026
  4. added
    ⏳Bot is counting down the days until it unassigns the issue
    on Jul 15, 2026
  5. flutter-triage-bot commented on Jul 15, 2026

    @flutter-triage-bot

    This issue is assigned to @hantrungkien but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  6. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterp: go_routerThe go_router packagep: go_router_builderThe go_router_builder packagepackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions