@@ -831,15 +831,37 @@ class Constraint {
831831 needsLayout = true ;
832832 }
833833
834+ int getMinimalConstraintCount (double size) {
835+ if (size == matchParent) {
836+ return 0 ;
837+ } else if (size == wrapContent || size >= 0 ) {
838+ return 1 ;
839+ } else {
840+ return 2 ;
841+ }
842+ }
843+
834844 if (parentData.width != width) {
835- parentData.width = width;
836845 needsRecalculateConstraints = true ;
846+ if (parentData.width != null ) {
847+ if (getMinimalConstraintCount (parentData.width! ) ==
848+ getMinimalConstraintCount (width)) {
849+ needsRecalculateConstraints = false ;
850+ }
851+ }
852+ parentData.width = width;
837853 needsLayout = true ;
838854 }
839855
840856 if (parentData.height != height) {
841- parentData.height = height;
842857 needsRecalculateConstraints = true ;
858+ if (parentData.height != null ) {
859+ if (getMinimalConstraintCount (parentData.height! ) ==
860+ getMinimalConstraintCount (height)) {
861+ needsRecalculateConstraints = false ;
862+ }
863+ }
864+ parentData.height = height;
843865 needsLayout = true ;
844866 }
845867
@@ -1155,7 +1177,7 @@ class _ConstraintRenderBox extends RenderBox
11551177 /// For layout
11561178 late List <_ConstrainedNode > _layoutOrderList;
11571179
1158- /// for paint
1180+ /// For paint
11591181 late List <_ConstrainedNode > _paintingOrderList;
11601182
11611183 static const int maxTimeUsage = 20 ;
@@ -1198,7 +1220,9 @@ class _ConstraintRenderBox extends RenderBox
11981220 set debugPrintConstraints (bool value) {
11991221 if (_debugPrintConstraints != value) {
12001222 _debugPrintConstraints = value;
1201- markNeedsRecalculateConstraints ();
1223+ if (value) {
1224+ markNeedsRecalculateConstraints ();
1225+ }
12021226 markNeedsLayout ();
12031227 }
12041228 }
@@ -1213,7 +1237,9 @@ class _ConstraintRenderBox extends RenderBox
12131237 set debugCheckConstraints (bool value) {
12141238 if (_debugCheckConstraints != value) {
12151239 _debugCheckConstraints = value;
1216- markNeedsRecalculateConstraints ();
1240+ if (value) {
1241+ markNeedsRecalculateConstraints ();
1242+ }
12171243 markNeedsLayout ();
12181244 }
12191245 }
@@ -1228,7 +1254,9 @@ class _ConstraintRenderBox extends RenderBox
12281254 set debugName (String ? value) {
12291255 if (_debugName != value) {
12301256 _debugName = value;
1231- markNeedsRecalculateConstraints ();
1257+ if (value != null ) {
1258+ markNeedsRecalculateConstraints ();
1259+ }
12321260 markNeedsLayout ();
12331261 }
12341262 }
@@ -1271,15 +1299,10 @@ class _ConstraintRenderBox extends RenderBox
12711299 _ConstraintBoxData childParentData =
12721300 child.parentData as _ConstraintBoxData ;
12731301
1274- assert (() {
1275- if (_debugCheckConstraints) {
1276- if (childParentData.width == null ) {
1277- throw ConstraintLayoutException (
1278- 'Must provide Constraint for child elements, try use Constrained widget.' );
1279- }
1280- }
1281- return true ;
1282- }());
1302+ if (childParentData.width == null ) {
1303+ throw ConstraintLayoutException (
1304+ 'Must provide Constraint for child elements, try use Constrained widget.' );
1305+ }
12831306
12841307 if (childParentData.id != null ) {
12851308 if (! idSet.add (childParentData.id! )) {
0 commit comments