Correct, UrlTemplate
does a naive prefix match, so /add
will match /address
.
If you are worried about conflicts between two routes where path of one happens to be a prefix of another, then the correct approach is to put the most specific path first. For example:
router.root
..addRoute(
name: 'address',
path: '/address',
enter: view('view/address.html'))
..addRoute(
name: 'add',
path: '/add',
enter: view('view/addRecipe.html'))
Router matches routes in the order they are specified, so it will pick the first that matches. This way /address
will always match address
route and /add
will always match add
route.
If you are worried about unintended matches of /addFoo
to /add
, at the moment I'm afraid there's no easy way to ensure that. If you feel strongly about it please file a feature request against the route_hierarchical package.