routemaster
routemaster copied to clipboard
[Question] Reusability of parts of the navigation tree
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?
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.
Very cool. Thanks a lot.