@@ -1669,10 +1669,18 @@ class _ConstraintRenderBox extends RenderBox
1669
1669
}
1670
1670
} else if (element.width == matchConstraint) {
1671
1671
if (element.widthHeightRatio == null ) {
1672
- if (element.leftConstraint == null ||
1673
- element.rightConstraint == null ) {
1674
- throw ConstraintLayoutException (
1675
- 'Need to set left and right constraints for ${element .nodeId }.' );
1672
+ if (element.widthPercentageAnchor == PercentageAnchor .constraint) {
1673
+ if (element.leftConstraint == null ||
1674
+ element.rightConstraint == null ) {
1675
+ throw ConstraintLayoutException (
1676
+ 'Need to set left and right constraints for ${element .nodeId }.' );
1677
+ }
1678
+ } else {
1679
+ if (element.leftConstraint == null &&
1680
+ element.rightConstraint == null ) {
1681
+ throw ConstraintLayoutException (
1682
+ 'Need to set a left or right constraint for ${element .nodeId }.' );
1683
+ }
1676
1684
}
1677
1685
} else {
1678
1686
if (element.leftConstraint == null &&
@@ -1701,16 +1709,24 @@ class _ConstraintRenderBox extends RenderBox
1701
1709
'When setting a baseline constraint for ${element .nodeId }, its height must be fixed or wrap_content.' );
1702
1710
}
1703
1711
if (element.widthHeightRatio == null ) {
1704
- if (element.topConstraint == null ||
1705
- element.bottomConstraint == null ) {
1706
- throw ConstraintLayoutException (
1707
- 'Need to set both top and bottom constraints for ${element .nodeId }.' );
1712
+ if (element.heightPercentageAnchor == PercentageAnchor .constraint) {
1713
+ if (element.topConstraint == null ||
1714
+ element.bottomConstraint == null ) {
1715
+ throw ConstraintLayoutException (
1716
+ 'Need to set both top and bottom constraints for ${element .nodeId }.' );
1717
+ }
1718
+ } else {
1719
+ if (element.topConstraint == null &&
1720
+ element.bottomConstraint == null ) {
1721
+ throw ConstraintLayoutException (
1722
+ 'Need to set a top or bottom constraints for ${element .nodeId }.' );
1723
+ }
1708
1724
}
1709
1725
} else {
1710
1726
if (element.topConstraint == null &&
1711
1727
element.bottomConstraint == null ) {
1712
1728
throw ConstraintLayoutException (
1713
- 'Need to set top or bottom constraints for ${element .nodeId }.' );
1729
+ 'Need to set a top or bottom constraints for ${element .nodeId }.' );
1714
1730
}
1715
1731
}
1716
1732
} else {
@@ -2817,14 +2833,20 @@ class _ConstrainedNode {
2817
2833
/// fixed size, matchParent, matchConstraint with two constraints
2818
2834
bool get widthIsExact =>
2819
2835
width >= 0 ||
2820
- (width != wrapContent &&
2836
+ (width == matchParent) ||
2837
+ (width == matchConstraint &&
2838
+ widthPercentageAnchor == PercentageAnchor .parent) ||
2839
+ (width == matchConstraint &&
2821
2840
leftConstraint != null &&
2822
2841
rightConstraint != null );
2823
2842
2824
2843
/// fixed size, matchParent, matchConstraint with two constraints
2825
2844
bool get heightIsExact =>
2826
2845
height >= 0 ||
2827
- (height != wrapContent &&
2846
+ (height == matchParent) ||
2847
+ (height == matchConstraint &&
2848
+ heightPercentageAnchor == PercentageAnchor .parent) ||
2849
+ (height == matchConstraint &&
2828
2850
(topConstraint != null && bottomConstraint != null ));
2829
2851
2830
2852
set offset (Offset value) {
0 commit comments