routerReportsNewRouteInformation method
- RouteInformation routeInformation, {
- RouteInformationReportingType type = RouteInformationReportingType.none,
A callback called when the Router widget reports new route information
The subclasses can override this method to update theirs values or trigger other side effects. For example, the PlatformRouteInformationProvider overrides this method to report the route information back to the engine.
The routeInformation
is the new route information generated by the
Router rebuild, and it can be the same or different from the
value.
The type
denotes the Router's intention when it reports this
routeInformation
. It is useful when deciding how to update the internal
state of RouteInformationProvider subclass with the routeInformation
.
For example, PlatformRouteInformationProvider uses this property to
decide whether to push or replace the browser history entry with the new
routeInformation
.
For more information on how Router determines a navigation event, see the "URL updates for web applications" section in the Router documentation.
Implementation
@override
void routerReportsNewRouteInformation(RouteInformation routeInformation, {RouteInformationReportingType type = RouteInformationReportingType.none}) {
SystemNavigator.selectMultiEntryHistory();
SystemNavigator.routeInformationUpdated(
uri: routeInformation.uri,
state: routeInformation.state,
replace: switch (type) {
RouteInformationReportingType.neglect => true,
RouteInformationReportingType.navigate => false,
RouteInformationReportingType.none => _equals(_valueInEngine.uri, routeInformation.uri),
},
);
_value = routeInformation;
_valueInEngine = routeInformation;
}