routerReportsNewRouteInformation method

  1. @override
void routerReportsNewRouteInformation(
  1. RouteInformation routeInformation,
  2. {RouteInformationReportingType type = RouteInformationReportingType.none}
)
override

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}) {
  final bool replace =
    type == RouteInformationReportingType.neglect ||
    (type == RouteInformationReportingType.none &&
    _equals(_valueInEngine.uri, routeInformation.uri));
  SystemNavigator.selectMultiEntryHistory();
  SystemNavigator.routeInformationUpdated(
    uri: routeInformation.uri,
    state: routeInformation.state,
    replace: replace,
  );
  _value = routeInformation;
  _valueInEngine = routeInformation;
}