Skip to content

Commit b37e7cc

Browse files
committed
Make resolvedConstraint overridable.
1 parent 87b3463 commit b37e7cc

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lib/src/api/node_processor.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extension NodeBoxHelper on NodeBox {
1616
double? y,
1717
double? width,
1818
double? height,
19+
BoxConstraintsModel? constraintOverrides,
1920
bool resetRetainedBox = true,
2021
bool recursivelyCalculateChildrenGlobalBoxes = true,
2122
bool triggerCompute = true,
@@ -28,10 +29,15 @@ extension NodeBoxHelper on NodeBox {
2829
);
2930
if (!triggerCompute) {
3031
node._basicBoxLocal = box;
32+
if (constraintOverrides != null) {
33+
node._resolvedConstraints =
34+
node._constraints.union(constraintOverrides);
35+
}
3136
} else {
3237
NodeProcessor.updateNode(
3338
node: node,
3439
basicBoxLocal: box,
40+
constraintOverrides: constraintOverrides,
3541
resetRetainedBox: resetRetainedBox,
3642
recursivelyCalculateChildrenGlobalBoxes:
3743
recursivelyCalculateChildrenGlobalBoxes,
@@ -305,6 +311,9 @@ class NodeProcessor {
305311
/// list of nodes one-by-one order from parent to child order. If this is
306312
/// the case, then we can make important assumptions that can help optimize
307313
/// and avoid recursive computation.
314+
///
315+
/// [constraintOverrides] overrides [node.resolvedConstraints] while being
316+
/// still affected by user given constraints.
308317
static void updateNode({
309318
required BaseNode node,
310319
EdgeInsetsModel? margin,
@@ -314,6 +323,7 @@ class NodeProcessor {
314323
OuterNodeBox? outerBoxGlobal,
315324
NodeBox? basicBoxLocal,
316325
BoxConstraintsModel? constraints,
326+
BoxConstraintsModel? constraintOverrides,
317327
int? rotationDegrees,
318328
bool resetRetainedBox = true,
319329
bool recursivelyCalculateChildrenGlobalBoxes = true,
@@ -340,7 +350,11 @@ class NodeProcessor {
340350
if (constraintsChanged) {
341351
node._constraints = constraints;
342352
}
343-
node._resolvedConstraints = resolveConstraints(node);
353+
if (constraintOverrides != null) {
354+
node._resolvedConstraints = node._constraints.union(constraintOverrides);
355+
} else {
356+
node._resolvedConstraints = resolveConstraints(node);
357+
}
344358

345359
node.updateNodeRotation(rotationDegrees ?? node.rotationDegrees);
346360

0 commit comments

Comments
 (0)