-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
In order to better support redirection, we should replace the redirection API with onEnter
and onExit
.
The onEnter
function is called when the new location results in a RouteMatch that was not previously present on RouteMatchList:
matchList = [ "/a"]
matchList' = [ "/a", "b"]
When matchList
changes to matchList'
, the onEnter
callback for Route "b" will be called, and the callback for "/a" will not.
The onExit
callback is invoked when the reverse is true:
matchList = [ "/a", "b"]
matchList' = [ "/a"]
When matchList
changes to matchList'
, the onExit
callback for Route "b" will be called.
biklas7, td-involio, ali-alizadeh, ElteHupkes, alexdecoder and 93 more
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]Add hook for when routes are removed[/-][+]Add onExit callback[/+][-]Add onExit callback[/-][+]Replace redirect with onEnter and onExit[/+][-]Replace redirect with onEnter and onExit[/-][+][go_router] Replace redirect with onEnter and onExit[/+]ElteHupkes commentedon Sep 21, 2022
Would it be possible to cancel / delay the route change through these callbacks? I feel like this could be a good mechanism to prevent route changes in case, for instance, a user has unsaved changes on the page you might want to warn them about.
johnpryan commentedon Sep 22, 2022
Yes, onExit would support this scenario, similar to how you would use WillPopScope. (WillPopScope doesn't work with page-backed routes, which built by the Router / go_router)
AceChen1 commentedon Nov 25, 2022
@chunhtai @johnpryan Hi guys, as we know, android app usually have a common requirement: when user on the root router, and then click the physical backward, will have a tips "click again to exist the app". previous navigator 1.0, i can use WillPopScope to listen & control the true/false to implement it, but i don't know how to implement it on the go router, any advice?
105 remaining items
flutter-triage-bot commentedon Dec 30, 2024
This issue was assigned to @chunhtai but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.
bogdanChernichenko commentedon May 10, 2025
So I guess no progress here?
omar-hanafy commentedon May 10, 2025
@bogdanChernichenko not really. We are making some progress in the top level on enter here
flutter-triage-bot commentedon Jun 5, 2025
The
triaged-go_router
label is irrelevant if there is noteam-go_router
label orfyi-go_router
label.