routemaster icon indicating copy to clipboard operation
routemaster copied to clipboard

[Question] Reusability of parts of the navigation tree

Open hffmnn opened this issue 4 years ago • 2 comments

Given the following RouteMap:

final routes = RouteMap(routes: {
  '/': (routeData) => MaterialPage(child: HomePage("/profile")),
  '/bookslist': (routeData) => MaterialPage(child: BooksList()),
  '/bookslist/bookDetail': (routeData) => MaterialPage(child: BookDetails()),
  '/bookslist/bookDetail/authorInfo': (routeData) => MaterialPage(child: AuthorInfo()),
  '/bookslist/bookDetail/cart': (routeData) => MaterialPage(child: Cart()),
});

I'd also like to add another navigation tree, where I can jump to a book detail directly, e.g. via a deeplink:

final routes = RouteMap(routes: {
  '/': (routeData) => MaterialPage(child: HomePage()),
  '/bookslist': (routeData) => MaterialPage(child: BooksList()),
  '/bookslist/bookDetail': (routeData) => MaterialPage(child: BookDetails()),
  '/bookslist/bookDetail/authorInfo': (routeData) => MaterialPage(child: AuthorInfo()),
  '/bookslist/bookDetail/cart': (routeData) => MaterialPage(child: Cart()),
  '/deeplink': (routeData) => MaterialPage(child: DeeplinkInfo()),
  '/deeplink/bookDetail': (routeData) => MaterialPage(child: BookDetails()),
  '/deeplink/bookDetail/authorInfo': (routeData) => MaterialPage(child: AuthorInfo()),
  '/deeplink/bookDetail/cart': (routeData) => MaterialPage(child: Cart()),
});

Is it somehow possible to model this without repeating every possible subnavigation under bookDetail? Or am I on the wrong track and one would model this completely different?

hffmnn avatar Nov 18 '21 17:11 hffmnn

Hello! Thanks for the question. This is going to be possible in the next version using child route maps.

Will post here when it's available in prerelease, hopefully next week.

tomgilder avatar Nov 20 '21 15:11 tomgilder

Very cool. Thanks a lot.

hffmnn avatar Dec 02 '21 10:12 hffmnn