render method
Starts rendering current route.
Implementation
Future<void> render() async {
var currentUrl = Uri.parse(window.location.href);
// TODO: currentPath and currentRoute should be set both at the same time
currentPath = currentUrl.path;
var isMatch = false;
for (var i in _matchMap.entries) {
var pattern = i.key;
var entry = i.value;
Map<String, String>? params;
if (entry.prefixMatch == null) {
params = _extractParamsAuto(pattern, currentUrl.path);
} else {
params = _extractParams(pattern, currentPath, prefixMatch: entry.prefixMatch!);
}
if (params == null) continue; // Does not match pattern, continue to the next
isMatch = true;
var route = entry.handleFunc(params, currentUrl.queryParameters);
if (currentRoute != null) {
if (doNotRenderSameRoute && currentRoute!.id == route.id) {
break;
} else {
await _unrenderCurrent();
}
}
currentRoute = route;
await _renderRoute(route);
break;
}
if (!isMatch) {
throw ComponentRouterNoMatchException(currentUrl.path, parentElement.id);
}
}