restoreRouteInformation method

  1. @override
RouteInformation? restoreRouteInformation(
  1. AppRouteState configuration
)
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(AppRouteState configuration) {
  final currentAppRoute =
      configuration.appRoutes[configuration.appRootRoute] ?? AppRoute.fleet;

  return RouteInformation(
    uri: Uri.parse(_encodeRoute(configuration.current ?? currentAppRoute)),
    state: {
      'appRoutes': {
        for (final entry in configuration.appRoutes.entries)
          _encodeRootRoute(entry.key): _encodeRoute(entry.value),
      },
      'appRootRoute': _encodeRootRoute(configuration.appRootRoute),
      'fleetView': configuration.fleetView.value,
      'fleetShowingDashboard': configuration.fleetShowingDashboard,
    },
  );
}