Flutter Navigator 2.0

Nov 8 2022 Dart 2.17.3, Flutter 3.0.2, Android Studio 2020.3

Part 4: Deep Links & Web Urls

22. Support Web Url

Episode complete

Play next episode

Next
Save for later
About this episode
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 21. Create a Route Information Parser Next episode: 23. Check the Deep Links & Remove # Symbol

This video Support Web Url was last updated on Nov 8 2022

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

Episode - 22 Support Web Urls

Now that our router is connected with routerInformation parser and is parsing the information, we have to map the URL path woth the pages so that our router displays them when needed. Firstly we have add the AppLink type to our BookRouterDelegate so that we can use it inside our delegate function.

BookRouterDelegate extends RouterDelegate<AppLink>
  @override
  Future<void> setNewRoutePath(AppLink newlink) async {
    switch (newlink.location) {
      case AppLink.homePath:
        appStateManager.login('anyusername', 'anypassword');
        break;
      case AppLink.itemPath:
        final itemId = newlink.itemId;
        if (itemId != null) {
          bookManager.setSelectedBookItem(itemId);
        }
    }
  }
  AppLink getCurrentpath() {
    if (appStateManager.isSignUp && !appStateManager.onSignUpComplete) {
      return AppLink(location: AppLink.signUpPath);
    } else if (!appStateManager.isLoggedIn &&
        appStateManager.isInitialized &&
        !appStateManager.onSignUpComplete) {
      return AppLink(location: AppLink.loginPath);
    } else if (appStateManager.onCheckout) {
      return AppLink(location: AppLink.checkoutPath);
    } else if (appStateManager.onMyBooks) {
      return AppLink(location: AppLink.myBookPath);
    } else if (appStateManager.onSettings && !appStateManager.onMyBooks) {
      return AppLink(location: AppLink.settingsPath);
    } else if (appStateManager.onCart) {
      return AppLink(location: AppLink.cartPath);
    } else if (bookManager.selectedBookItem != null &&
        appStateManager.onReadBook) {
      final id = bookManager.selectedBookItem?.id;
      return AppLink(location: AppLink.readBookPath, itemId: id);
    } else if (bookManager.selectedBookItem != null) {
      final id = bookManager.selectedBookItem?.id;
      return AppLink(location: AppLink.itemPath, itemId: id);
    } else if (appStateManager.onSignUpComplete && !appStateManager.isSignUp ||
        appStateManager.isLoggedIn) {
      return AppLink(location: AppLink.homePath);
    } else {
      return AppLink(location: AppLink.splashPath);
    }
  }
  @override
  AppLink get currentConfiguration => getCurrentpath();