applyPartialExpansion method
Temporarily move partial children from hiddenChildren to children.
Used during layout serialization to show partial children as visible
to the layout engine. Call restorePartialExpansion after serialization.
Implementation
void applyPartialExpansion() {
if (isPartiallyExpanded &&
hiddenChildren != null &&
hiddenChildren!.isNotEmpty) {
final toReveal = <LayoutNode>[];
hiddenChildren!.removeWhere((child) {
if (partialChildIds!.contains(child.id)) {
toReveal.add(child);
return true;
}
return false;
});
children.addAll(toReveal);
}
// Recurse into visible children (which may themselves be partially
// expanded) and hidden children (which may have been partially
// expanded before being hidden)
for (final child in children) {
child.applyPartialExpansion();
}
for (final child in hiddenChildren ?? <LayoutNode>[]) {
child.applyPartialExpansion();
}
}