ポイント2について:
次のようにすることができますか?:
URL の変数部分は、' window.location.pathname ' によって設定されます。
library urls;
import 'dart:html';
import 'package:route/client.dart';
final String _pathName = window.location.pathname;
final UrlPattern _base = new UrlPattern("${_pathName}");
final UrlPattern home = new UrlPattern("${_pathName}#home");
final UrlPattern page2 = new UrlPattern("${_pathName}#page2");
// useFragment: true is important! allow keep '#" un url
// allow to bookmark be valid when browser is closed and reopen.
final Router router = new Router(useFragment: true)
// simple hack to redirect / to /#home (home UrlPattern)
..addHandler(_base, (_) => window.location.hash = "#home");
main() {
router..addHandler(home, showHome)
..addHandler(page2, showPage2)
..listen();
}
void showHome(String path) {
query("body").children
..clear()
..add(new Element.html("<h1>Home</H1>"));
}
void showPage2(String path) {
query("body").children
..clear()
..add(new Element.html("<h1>Page2</H1>"));
}