toHierarchy static method
Converts a list of linear route matches to
to a hierarchy of routes
e.g Match1,Match2,Match3
will be [Match1[Match2Match3
]]
Implementation
static RouteMatch toHierarchy(List<RouteMatch> segments) {
if (segments.length == 1) {
return segments.first;
} else {
return segments.first.copyWith(children: [
toHierarchy(
segments.sublist(1, segments.length),
),
]);
}
}