restoreRouteInformation method

  1. @override
RouteInformation restoreRouteInformation(
  1. SplitRoutePath path
)
override

Restore the route information from the given configuration.

This may return null, in which case the browser history will not be updated and state restoration is disabled. See Router's documentation for details.

The parseRouteInformation method must produce an equivalent configuration when passed this method's return value.

Implementation

@override
RouteInformation restoreRouteInformation(SplitRoutePath path) {
  var location = path.pageInstances
      .where((i) => i is KeyPageInstance || i is AnonymousPage)
      .map(
    (i) {
      if (i is KeyPageInstance)
        return [i.keyPage.key, ...i.param].join("/");
      else
        return (i as AnonymousPage).keyNumber;
    },
  ).join("/");

  return RouteInformation(location: "/$location");
}