suggestFromChain static method
Generate suggestions from a constraint chain analysis.
This uses the full chain of constraints from root to the overflowing widget to identify WHERE the constraint became problematic.
Implementation
static List<FixSuggestion> suggestFromChain(
LayoutDecision decision,
List<ConstraintChainLink> chain,
) {
final suggestions = suggest(decision);
// Find the link where unbounded constraints were introduced
for (int i = 0; i < chain.length; i++) {
final link = chain[i];
if (link.constraints is BoxConstraints &&
((link.constraints as BoxConstraints).maxWidth == double.infinity ||
(link.constraints as BoxConstraints).maxHeight ==
double.infinity)) {
final widgetName = link.widgetType;
suggestions.insert(
0,
FixSuggestion(
description: 'Unbounded constraint introduced at $widgetName '
'(level $i in the chain)',
codeHint: 'Add constraints to $widgetName or its parent',
confidence: 0.85,
priority: 0,
category: FixCategory.constrainDimensions,
),
);
break;
}
}
return suggestions;
}