Skip to content

Commit 70608dd

Browse files
author
fbchen
committed
optimize constriants calculate
1 parent 5785930 commit 70608dd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/src/constraint_layout.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ bool _debugEnsureNegativePercent(String name, double? percent) {
330330
}
331331

332332
final ConstraintId parent = ConstraintId('parent');
333+
final _ConstrainedNode _parentNode = _ConstrainedNode()..nodeId = parent;
333334
const double matchConstraint = -3.1415926;
334335
const double matchParent = -2.7182818;
335336
const double wrapContent = -0.6180339;
@@ -1435,6 +1436,9 @@ class _ConstraintRenderBox extends RenderBox
14351436
Map<ConstraintId, _ConstrainedNode> nodesMap = HashMap();
14361437

14371438
_ConstrainedNode _getConstrainedNodeForChild(ConstraintId id) {
1439+
if (id == parent) {
1440+
return _parentNode;
1441+
}
14381442
_ConstrainedNode? node = nodesMap[id];
14391443
if (node == null) {
14401444
node = _ConstrainedNode()..nodeId = id;
@@ -1452,7 +1456,8 @@ class _ConstraintRenderBox extends RenderBox
14521456
childParentData._constrainedNodeMap = nodesMap;
14531457

14541458
_ConstrainedNode currentNode = _getConstrainedNodeForChild(
1455-
childParentData.id ?? ConstraintId('child[$childIndex]'));
1459+
childParentData.id ??
1460+
ConstraintId('child[$childIndex]@${child.runtimeType}'));
14561461
currentNode.parentData = childParentData;
14571462
currentNode.index = childIndex;
14581463
currentNode.renderBox = child;

0 commit comments

Comments
 (0)