@@ -1669,10 +1669,18 @@ class _ConstraintRenderBox extends RenderBox
16691669 }
16701670 } else if (element.width == matchConstraint) {
16711671 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+ }
16761684 }
16771685 } else {
16781686 if (element.leftConstraint == null &&
@@ -1701,16 +1709,24 @@ class _ConstraintRenderBox extends RenderBox
17011709 'When setting a baseline constraint for ${element .nodeId }, its height must be fixed or wrap_content.' );
17021710 }
17031711 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+ }
17081724 }
17091725 } else {
17101726 if (element.topConstraint == null &&
17111727 element.bottomConstraint == null ) {
17121728 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 }.' );
17141730 }
17151731 }
17161732 } else {
@@ -2817,14 +2833,20 @@ class _ConstrainedNode {
28172833 /// fixed size, matchParent, matchConstraint with two constraints
28182834 bool get widthIsExact =>
28192835 width >= 0 ||
2820- (width != wrapContent &&
2836+ (width == matchParent) ||
2837+ (width == matchConstraint &&
2838+ widthPercentageAnchor == PercentageAnchor .parent) ||
2839+ (width == matchConstraint &&
28212840 leftConstraint != null &&
28222841 rightConstraint != null );
28232842
28242843 /// fixed size, matchParent, matchConstraint with two constraints
28252844 bool get heightIsExact =>
28262845 height >= 0 ||
2827- (height != wrapContent &&
2846+ (height == matchParent) ||
2847+ (height == matchConstraint &&
2848+ heightPercentageAnchor == PercentageAnchor .parent) ||
2849+ (height == matchConstraint &&
28282850 (topConstraint != null && bottomConstraint != null ));
28292851
28302852 set offset (Offset value) {
0 commit comments