setNewRoutePath method

  1. @override
Future<void> setNewRoutePath(
  1. UrlState 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(UrlState configuration) async {
  final topMost = controller.topMostRouter();
  if (topMost is StackRouter && topMost.hasPagelessTopRoute) {
    topMost.popUntil((route) => route.settings is Page);
  }

  if (configuration.hasSegments) {
    final platLink = PlatformDeepLink._(configuration, false);
    final resolvedLink =
        deepLinkBuilder == null ? platLink : await deepLinkBuilder!(platLink);
    if (rebuildStackOnDeepLink) {
      controller.popUntil((route) => false);
    }
    await _handleDeepLink(resolvedLink);
  }

  notifyListeners();
  return SynchronousFuture(null);
}