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
About this episode
Leave a rating/review
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

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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();