@@ -3156,27 +3156,28 @@ class _ConstraintRenderBox extends RenderBox
3156
3156
list.add (node.parentData._constrainedNodeMap[id]! .getBottom ());
3157
3157
}
3158
3158
}
3159
- list.sort ((left, right) {
3160
- if (left > right) {
3161
- return 1 ;
3162
- } else if (left == right) {
3163
- return 0 ;
3164
- } else {
3165
- return - 1 ;
3159
+ double min = double .maxFinite;
3160
+ double max = double .minPositive;
3161
+ for (final element in list) {
3162
+ if (element > max) {
3163
+ max = element;
3166
3164
}
3167
- });
3165
+ if (element < min) {
3166
+ min = element;
3167
+ }
3168
+ }
3168
3169
if (direction == BarrierDirection .left) {
3169
- offsetX = list.first ;
3170
+ offsetX = min ;
3170
3171
offsetY = 0 ;
3171
3172
} else if (direction == BarrierDirection .top) {
3172
3173
offsetX = 0 ;
3173
- offsetY = list.first ;
3174
+ offsetY = min ;
3174
3175
} else if (direction == BarrierDirection .right) {
3175
- offsetX = list.last ;
3176
+ offsetX = max ;
3176
3177
offsetY = 0 ;
3177
3178
} else {
3178
3179
offsetX = 0 ;
3179
- offsetY = list.last ;
3180
+ offsetY = max ;
3180
3181
}
3181
3182
} else {
3182
3183
/// Calculate child x offset
@@ -3830,11 +3831,8 @@ class _ConstrainedNode {
3830
3831
return baseline;
3831
3832
}
3832
3833
3833
- int getDepthFor (_ConstrainedNode ? constrainedNode, bool ? parentSizeConfirmed,
3834
+ int getDepthFor (_ConstrainedNode constrainedNode, bool ? parentSizeConfirmed,
3834
3835
double ? resolvedWidth, double ? resolvedHeight) {
3835
- if (constrainedNode == null ) {
3836
- return - 1 ;
3837
- }
3838
3836
if (parentSizeConfirmed == false ) {
3839
3837
if (constrainedNode.isParent ()) {
3840
3838
/// The width and height can be calculated directly without relying on parent
@@ -3861,23 +3859,26 @@ class _ConstrainedNode {
3861
3859
list.add (parentData._constrainedNodeMap[id]!
3862
3860
.getDepth (parentSizeConfirmed, resolvedWidth, resolvedHeight));
3863
3861
}
3864
- list.sort ((left, right) => left - right);
3865
- depth = list.last + 1 ;
3862
+ depth = list.reduce (max) + 1 ;
3866
3863
} else {
3867
3864
List <int > list = [
3868
- getDepthFor (leftConstraint, parentSizeConfirmed, resolvedWidth,
3869
- resolvedHeight),
3870
- getDepthFor (topConstraint, parentSizeConfirmed, resolvedWidth,
3871
- resolvedHeight),
3872
- getDepthFor (rightConstraint, parentSizeConfirmed, resolvedWidth,
3873
- resolvedHeight),
3874
- getDepthFor (bottomConstraint, parentSizeConfirmed, resolvedWidth,
3875
- resolvedHeight),
3876
- getDepthFor (baselineConstraint, parentSizeConfirmed, resolvedWidth,
3877
- resolvedHeight),
3865
+ if (leftConstraint != null )
3866
+ getDepthFor (leftConstraint! , parentSizeConfirmed, resolvedWidth,
3867
+ resolvedHeight),
3868
+ if (topConstraint != null )
3869
+ getDepthFor (topConstraint! , parentSizeConfirmed, resolvedWidth,
3870
+ resolvedHeight),
3871
+ if (rightConstraint != null )
3872
+ getDepthFor (rightConstraint! , parentSizeConfirmed, resolvedWidth,
3873
+ resolvedHeight),
3874
+ if (bottomConstraint != null )
3875
+ getDepthFor (bottomConstraint! , parentSizeConfirmed, resolvedWidth,
3876
+ resolvedHeight),
3877
+ if (baselineConstraint != null )
3878
+ getDepthFor (baselineConstraint! , parentSizeConfirmed, resolvedWidth,
3879
+ resolvedHeight),
3878
3880
];
3879
- list.sort ((left, right) => left - right);
3880
- depth = list.last + 1 ;
3881
+ depth = list.reduce (max) + 1 ;
3881
3882
}
3882
3883
}
3883
3884
return depth;
0 commit comments