explain static method
Generate a human-readable explanation of the constraint chain.
Implementation
static String explain(List<ConstraintChainLink> chain) {
if (chain.isEmpty) return 'Empty constraint chain.';
final buffer = StringBuffer();
buffer.writeln('Constraint Chain Analysis:');
buffer.writeln('─' * 50);
for (final link in chain) {
final indent = ' ' * link.depth;
final tight = link.isTight ? ' ⚠️ TIGHT' : '';
buffer.writeln(
'$indent[${link.depth}] ${link.widgetType}$tight',
);
buffer.writeln(
'$indent constraints: ${link.constraints}',
);
if (link.size != null) {
buffer.writeln(
'$indent size: ${link.size}',
);
}
}
final culprit = findTightCulprit(chain);
if (culprit != null) {
buffer.writeln();
buffer.writeln('LIKELY CULPRIT: ${culprit.widgetType} at depth '
'${culprit.depth} imposes tight constraints.');
}
return buffer.toString();
}