handleNewRoute method

Future<bool> handleNewRoute(
  1. String? route
)

Overrides the root behavior to allow us to interpret browser route pushes that should be treated as pop instead of push.

If we handle the method here, it will not be passed on to the delegate

Maybe this should move to delegate?

Implementation

Future<bool> handleNewRoute(String? route) {
  // Look backwards in history for a match, then pop routes to match.
  // if (route == null) return SynchronousFuture(false);
  // var matches = state.matchHistory(route);
  // if (matches.isNotEmpty) {
  //   // Pop the route
  //   for (var match in matches) {
  //     if (match.tab != null) {
  //       if (match.tab != state.currTab) {
  //         log.info(
  //             "platform:didPushRouteInformation > move tab ${match.tab}");
  //         state.currTab = match.tab;
  //       } else {
  //         var tabNavState =
  //             state.tabState[match.tab!].navigatorKey.currentState!;
  //         if (tabNavState.canPop() == true) {
  //           tabNavState.popUntil((route) {
  //             var isPath = route.path == route;
  //             if (!isPath) {
  //               log.info(
  //                   "platform:didPushRouteInformation ^ popped ${match.route}");
  //             }
  //             return isPath;
  //           });
  //         } else {
  //           log.warning(
  //               "platform:didPushRouteInformation ! unable to pop ${match.tab}");
  //         }
  //       }
  //     } else {
  //       //pop root?
  //       log.warning("platform:didPushRouteInformation can't pop root (TBD)");
  //     }
  //   }
  //
  //   return SynchronousFuture(true);
  // } else {
  //   /// How do we know where to push this route?
  //
  //   log.warning(() {
  //     var str = "";
  //     str +=
  //         'platform:didPushRouteInformation No found routes for ${route}\n';
  //     str += '  in ->\n';
  //     if (state.history.isEmpty) {
  //       str += '    - no history\n';
  //     } else {
  //       str +=
  //           '    - ${state.history.map((element) => element.route).join('\n    - ')}';
  //     }
  //     return str;
  //   });
  // }
  return super.didPushRoute(route!);
}