analyze static method
Analyze the constraint chain from target up to the root
(or up to maxDepth ancestors).
Returns a list of ConstraintChainLinks ordered from the target (depth 0) to the furthest ancestor analyzed.
Implementation
static List<ConstraintChainLink> analyze(
RenderObject target, {
int maxDepth = 20,
}) {
final chain = <ConstraintChainLink>[];
RenderObject? current = target;
int depth = 0;
while (current != null && depth <= maxDepth) {
Size? size;
if (current is RenderBox && current.hasSize) {
size = current.size;
}
// ignore: invalid_use_of_protected_member
final currentConstraints = current.constraints;
chain.add(ConstraintChainLink(
widgetType: current.runtimeType.toString(),
constraints: currentConstraints,
size: size,
depth: depth,
));
current = current.parent;
depth++;
}
return chain;
}