1) I do not know how to do this. You can listen for each url (. *), And then manually check if $ path matches a different url, but this is messy:
var homeUrl = new UrlPattern(r'/home'); var contactUrl = new UrlPattern(r'/contact'); var router = new Router() ..addHandler(new url.UrlPattern(r'(.*)'), matchPages) ..listen(); void matchPages(String path) { if(homeUrl.matches(path)) { // Handle home page display } else if(contactUrl.matches(path)) { // Contact page } else { // No match, handle it how you wish } }
It would be nice to have a built-in way to pass default routes on the client.
2) Justin Fagnani (author of the Route package) indicates that you can either service your application from a separate web server (i.e. not one provided by the Dart Editor) or use a route that will also correspond to the file system path: (. * ) # the article will match the article correctly, whether the URL is localhost: 3030 / # article or C: / Dart / app / web // from / # the article. There is an open issue for Github: https://github.com/dart-lang/route/issues/31
source share