setNewRoutePath method

  1. @override
Future<void> setNewRoutePath(
  1. PageConfiguration 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(PageConfiguration configuration) async {

  // initialize
  if (pages.isNotEmpty && pages.first == dummyPage) {

    // clear all pages
    _pages.clear();

    // get home page
    String homePage = System.currentApp?.homePage ?? "store";

    // get start page
    String startPage = System.currentApp?.startPage ?? homePage;

    // start page is different than home page?
    if (homePage != startPage) {

      // get the start page
      bool linkable = await _pageLinkable(startPage) ?? System.currentApp?.singlePage ?? false;

      // set start page = home page if not linkable
      if (!linkable) startPage = homePage;

      // single page applications always load the home page
      if (System.currentApp?.singlePage ?? true) startPage = homePage;
    }

    // open the page
    return navigateTo(startPage);
  }

  // get url
  String? url = configuration.uri?.toString();

  // deeplink specified
  if (!FmlEngine.isWeb) {
    url = await _buildDeeplinkUrl(url);
  }

  // open the url
  return navigateTo(url, transition: configuration.transition);
}