setNewRoutePath method

  1. @override
Future<void> setNewRoutePath(
  1. RouteInformation configuration
)
override

Called by the Router when the Router.routeInformationProvider reports that a new route has been pushed to the application by the operating system.

Consider using a SynchronousFuture if the result can be computed synchronously, so that the Router does not need to wait for the next microtask to schedule a build.

Implementation

@override
Future<void> setNewRoutePath(RouteInformation configuration) {
  late Uri uri;
  try {
    uri = configuration.uri;
  } catch (e) {
    return SynchronousFuture(null); // coverage:ignore-line
  }

  _root.stagedChildPathSegments = uri.pathSegments;
  final Map<String, String> uriParams = {};

  if (uri.hasQuery) {
    final stagedParams = _root.stagedParams;
    uri.queryParameters.forEach((key, value) {
      if (stagedParams.containsKey(key)) {
        stagedParams[key]!.stringValue = value;
      } else {
        uriParams[key] = value;
      }
    });
  }

  _root.uriParams = uriParams;

  return SynchronousFuture(null);
}