Skip to content

Commit 572d7c4

Browse files
committed
fix barrier size
1 parent 06bb55a commit 572d7c4

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

lib/src/constraint_layout.dart

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,15 @@ extension ConstrainedWidgetsExt on Widget {
534534
child: this,
535535
);
536536
}
537+
538+
Widget debugWrap([Color? color]) {
539+
return Center(
540+
child: Container(
541+
color: color ?? Colors.black,
542+
child: this,
543+
),
544+
);
545+
}
537546
}
538547

539548
class OffBuildWidget extends StatelessWidget {
@@ -2606,6 +2615,14 @@ class _ConstraintRenderBox extends RenderBox
26062615
double contentBottom = -double.infinity;
26072616
for (int j = 0; j < i; j++) {
26082617
_ConstrainedNode sizeConfirmedChild = _layoutOrderList[j];
2618+
if (sizeConfirmedChild.isBarrier) {
2619+
if (sizeConfirmedChild.direction == BarrierDirection.top ||
2620+
sizeConfirmedChild.direction == BarrierDirection.bottom) {
2621+
sizeConfirmedChild.helperSize = Size(size.width, 0);
2622+
} else {
2623+
sizeConfirmedChild.helperSize = Size(0, size.height);
2624+
}
2625+
}
26092626
sizeConfirmedChild.offset = calculateChildOffset(sizeConfirmedChild);
26102627
EdgeInsets margin = sizeConfirmedChild.margin;
26112628
EdgeInsets goneMargin = sizeConfirmedChild.goneMargin;
@@ -2672,6 +2689,14 @@ class _ConstraintRenderBox extends RenderBox
26722689
: resolvedHeight);
26732690
for (int j = 0; j < i; j++) {
26742691
_ConstrainedNode sizeConfirmedChild = _layoutOrderList[j];
2692+
if (sizeConfirmedChild.isBarrier) {
2693+
if (sizeConfirmedChild.direction == BarrierDirection.top ||
2694+
sizeConfirmedChild.direction == BarrierDirection.bottom) {
2695+
sizeConfirmedChild.helperSize = Size(size.width, 0);
2696+
} else {
2697+
sizeConfirmedChild.helperSize = Size(0, size.height);
2698+
}
2699+
}
26752700
sizeConfirmedChild.offset = calculateChildOffset(sizeConfirmedChild);
26762701
if (sizeConfirmedChild.callback != null) {
26772702
sizeConfirmedChild.callback!.call(
@@ -2911,9 +2936,7 @@ class _ConstraintRenderBox extends RenderBox
29112936
}
29122937

29132938
/// Helper widgets may have no RenderObject
2914-
if (element.renderBox == null) {
2915-
element.helperSize = Size(minWidth, minHeight);
2916-
} else {
2939+
if (element.renderBox != null) {
29172940
/// Due to the design of the Flutter framework, even if a child element is gone, it still has to be laid out
29182941
/// I don't understand why the official design is this way
29192942
element.renderBox!.layout(
@@ -2925,7 +2948,18 @@ class _ConstraintRenderBox extends RenderBox
29252948
),
29262949
parentUsesSize: true,
29272950
);
2928-
if (element.isGuideline || element.isBarrier) {
2951+
}
2952+
if (element.isGuideline) {
2953+
element.helperSize = Size(minWidth, minHeight);
2954+
} else if (element.isBarrier) {
2955+
if (selfSizeConfirmed) {
2956+
if (element.direction == BarrierDirection.top ||
2957+
element.direction == BarrierDirection.bottom) {
2958+
element.helperSize = Size(size.width, 0);
2959+
} else {
2960+
element.helperSize = Size(0, size.height);
2961+
}
2962+
} else {
29292963
element.helperSize = Size(minWidth, minHeight);
29302964
}
29312965
}

0 commit comments

Comments
 (0)