getSubTrees method
List<_SubTree>
getSubTrees(
)
Implementation
List<_SubTree> getSubTrees() {
final List<MapEntry<_PageWithPosition, List<_PageWithPosition>>>
treesEntries = [];
asMap().entries.forEach((entry) {
final index = entry.key;
final page = entry.value;
if (page.route.isSubRoot) {
treesEntries.add(MapEntry(
_PageWithPosition(
customPage: page,
position: index,
),
[],
));
} else if (!page.route.isSubRoot) {
if (treesEntries.isNotEmpty) {
treesEntries.last.value.add(
_PageWithPosition(
customPage: page,
position: index,
),
);
} else {
return;
}
}
});
return treesEntries.map((e) {
return _SubTree(
root: e.key,
children: e.value,
);
}).toList();
}