getRootPanelElements static method
Returns all the panel elements from "root".
Typically, we get only the "health_card" and "environment_card" panels.
In option, only the one matching panelId.
Implementation
static List<KnowledgePanelElement> getRootPanelElements(
Product product, {
required bool simplified,
String? panelId,
}) {
final List<KnowledgePanelElement> result = <KnowledgePanelElement>[];
final KnowledgePanel? root = getRootKnowledgePanel(
product,
simplified: simplified,
);
if (root == null) {
return result;
}
if (root.elements == null) {
return result;
}
for (final KnowledgePanelElement panelElement in root.elements!) {
if (panelElement.elementType != KnowledgePanelElementType.PANEL) {
continue;
}
// no filter
if (panelId == null) {
result.add(panelElement);
} else {
if (panelId == panelElement.panelElement!.panelId) {
result.add(panelElement);
return result;
}
}
}
return result;
}