getBreadcrumbs method
Get all nodes in the breadcrumb path for a given node
Implementation
Future<List<Node>> getBreadcrumbs(String nodeId) async {
final node = await _repository.get(nodeId);
final ancestorPaths =
PathHashGenerator.getAncestorPaths(node.validPathHash);
final breadcrumbs = <Node>[];
for (final path in ancestorPaths) {
final pathNodes = await _repository.query(query: NodePathQuery(path));
final exactMatch =
pathNodes.where((n) => n.validPathHash == path).firstOrNull;
if (exactMatch != null) {
breadcrumbs.add(exactMatch);
}
}
return breadcrumbs;
}