[Proposal] Router
api allow to replace state
#116491
Labels
c: new feature
Nothing broken; request for a new capability
c: proposal
A detailed proposal for a change to Flutter
f: routes
Navigator, Router, and related APIs.
framework
flutter/packages/flutter repository. See also f: labels.
P3
Issues that are less important to the Flutter project
team-framework
Owned by Framework team
triaged-framework
Triaged by Framework team
Use case
Imagine a situation where user wants to navigate to
/
then the app starts to check authentication status which is currentlyunknown
(neither loggen in nor logged out) so I don't want to replace current url however I want to put some state in history (for instance to detect forward / backward actions).In JS world History.replaceState's 3. parameter
url
is optional to achive this kind of behavior or just by passing''
,null
,undefined
as the third parameter.
Currently RouteInformationParser.restoreRouteInformation can return
null
to indicate not to update history.RouteInformation
'slocation
property can also benull
however usingnull
will throw exception (what is the meaning ofnull
?).If I pass an empty string
''
toRouteInformation.location
then it will cause unexpected results like this:/
RouteInformationParser.restoreRouteInformation
returnsRouteInformation(location: '', state: state)
since authentication status isunknown
state
RouteInformationParser.restoreRouteInformation
returnsRouteInformation(location: '/', state: state)
'/'
instead of one.Proposal
If you look at
PlatformRouteInformationProvider
's current implementation:null
means inRouteInformation.location
._value
/_valueInEngine
shouldn't saveRouteInformation
if it's location is''
just copy the old one with the newstate
.final bool replace
should handle specials cases like whenRouteInformation.location
is''
ornull
.This is a possible implementation:
The text was updated successfully, but these errors were encountered: