@@ -31,6 +31,8 @@ class ConstraintLayout extends MultiChildRenderObjectWidget {
3131 /// When size is non-null, both width and height are set to size
3232 final double ? size;
3333
34+ final ConstraintVersion ? constraintVersion;
35+
3436 ConstraintLayout ({
3537 Key ? key,
3638 this .childConstraints,
@@ -47,6 +49,7 @@ class ConstraintLayout extends MultiChildRenderObjectWidget {
4749 this .width = matchParent,
4850 this .height = matchParent,
4951 this .size,
52+ this .constraintVersion,
5053 }) : super (
5154 key: key,
5255 children: children,
@@ -77,7 +80,8 @@ class ConstraintLayout extends MultiChildRenderObjectWidget {
7780 .._debugShowZIndex = debugShowZIndex
7881 .._debugShowChildDepth = debugShowChildDepth
7982 .._width = selfWidth
80- .._height = selfHeight;
83+ .._height = selfHeight
84+ .._constraintVersion = constraintVersion? .copy ();
8185 }
8286
8387 @override
@@ -108,7 +112,8 @@ class ConstraintLayout extends MultiChildRenderObjectWidget {
108112 ..debugShowZIndex = debugShowZIndex
109113 ..debugShowChildDepth = debugShowChildDepth
110114 ..width = selfWidth
111- ..height = selfHeight;
115+ ..height = selfHeight
116+ ..constraintVersion = constraintVersion? .copy ();
112117 }
113118}
114119
@@ -1025,6 +1030,68 @@ class PinnedInfo {
10251030 targetPos.hashCode;
10261031}
10271032
1033+ class ConstraintVersion {
1034+ int _constraintsVersion = 1 ;
1035+ int _layoutVersion = 1 ;
1036+ int _paintVersion = 1 ;
1037+ int _paintingOrderVersion = 1 ;
1038+ int _eventOrderVersion = 1 ;
1039+
1040+ ConstraintVersion incConstraintsVersion () {
1041+ _constraintsVersion++ ;
1042+ return this ;
1043+ }
1044+
1045+ ConstraintVersion incLayoutVersion () {
1046+ _layoutVersion++ ;
1047+ return this ;
1048+ }
1049+
1050+ ConstraintVersion incPaintVersion () {
1051+ _paintVersion++ ;
1052+ return this ;
1053+ }
1054+
1055+ ConstraintVersion incPaintingOrderVersion () {
1056+ _paintingOrderVersion++ ;
1057+ _eventOrderVersion++ ;
1058+ return this ;
1059+ }
1060+
1061+ ConstraintVersion incEventOrderVersion () {
1062+ _eventOrderVersion++ ;
1063+ return this ;
1064+ }
1065+
1066+ ConstraintVersion copy () {
1067+ return ConstraintVersion ()
1068+ .._constraintsVersion = _constraintsVersion
1069+ .._layoutVersion = _layoutVersion
1070+ .._paintVersion = _paintVersion
1071+ .._paintingOrderVersion = _paintingOrderVersion
1072+ .._eventOrderVersion = _eventOrderVersion;
1073+ }
1074+
1075+ @override
1076+ bool operator == (Object other) =>
1077+ identical (this , other) ||
1078+ other is ConstraintVersion &&
1079+ runtimeType == other.runtimeType &&
1080+ _constraintsVersion == other._constraintsVersion &&
1081+ _layoutVersion == other._layoutVersion &&
1082+ _paintVersion == other._paintVersion &&
1083+ _paintingOrderVersion == other._paintingOrderVersion &&
1084+ _eventOrderVersion == other._eventOrderVersion;
1085+
1086+ @override
1087+ int get hashCode =>
1088+ _constraintsVersion.hashCode ^
1089+ _layoutVersion.hashCode ^
1090+ _paintVersion.hashCode ^
1091+ _paintingOrderVersion.hashCode ^
1092+ _eventOrderVersion.hashCode;
1093+ }
1094+
10281095class Constraint extends ConstraintDefine {
10291096 /// 'wrap_content'、'match_parent'、'match_constraint'、'48, etc'
10301097 /// 'match_parent' will be converted to the base constraints
@@ -1422,6 +1489,16 @@ class Constraint extends ConstraintDefine {
14221489 return true ;
14231490 }
14241491
1492+ static int getMinimalConstraintCount (double size) {
1493+ if (size == matchParent) {
1494+ return 0 ;
1495+ } else if (size == wrapContent || size >= 0 ) {
1496+ return 1 ;
1497+ } else {
1498+ return 2 ;
1499+ }
1500+ }
1501+
14251502 void applyTo (RenderObject renderObject) {
14261503 _Align ? left = this .left;
14271504 _Align ? top = this .top;
@@ -1697,6 +1774,45 @@ class Constraint extends ConstraintDefine {
16971774
16981775 _ConstraintBoxData parentData =
16991776 renderObject.parentData! as _ConstraintBoxData ;
1777+ parentData.clickPadding = clickPadding;
1778+ parentData.callback = callback;
1779+
1780+ if ((renderObject.parent as _ConstraintRenderBox )._constraintVersion !=
1781+ null ) {
1782+ parentData.id = id;
1783+ parentData.width = width;
1784+ parentData.height = height;
1785+ parentData.visibility = visibility;
1786+ parentData.percentageMargin = percentageMargin;
1787+ parentData.margin = margin;
1788+ parentData.goneMargin = goneMargin;
1789+ parentData.left = left;
1790+ parentData.right = right;
1791+ parentData.top = top;
1792+ parentData.bottom = bottom;
1793+ parentData.baseline = baseline;
1794+ parentData.textBaseline = textBaseline;
1795+ parentData.zIndex = zIndex;
1796+ parentData.translateConstraint = translateConstraint;
1797+ parentData.translate = translate;
1798+ parentData.widthPercent = widthPercent;
1799+ parentData.heightPercent = heightPercent;
1800+ parentData.widthPercentageAnchor = widthPercentageAnchor;
1801+ parentData.heightPercentageAnchor = heightPercentageAnchor;
1802+ parentData.horizontalBias = horizontalBias;
1803+ parentData.verticalBias = verticalBias;
1804+ parentData.percentageTranslate = percentageTranslate;
1805+ parentData.minWidth = minWidth;
1806+ parentData.maxWidth = maxWidth;
1807+ parentData.minHeight = minHeight;
1808+ parentData.maxHeight = maxHeight;
1809+ parentData.widthHeightRatio = widthHeightRatio;
1810+ parentData.ratioBaseOnWidth = ratioBaseOnWidth;
1811+ parentData.eIndex = eIndex;
1812+ parentData.pinnedInfo = pinnedInfo;
1813+ return ;
1814+ }
1815+
17001816 bool needsLayout = false ;
17011817 bool needsPaint = false ;
17021818 bool needsReorderPaintingOrder = false ;
@@ -1709,16 +1825,6 @@ class Constraint extends ConstraintDefine {
17091825 needsLayout = true ;
17101826 }
17111827
1712- int getMinimalConstraintCount (double size) {
1713- if (size == matchParent) {
1714- return 0 ;
1715- } else if (size == wrapContent || size >= 0 ) {
1716- return 1 ;
1717- } else {
1718- return 2 ;
1719- }
1720- }
1721-
17221828 if (parentData.width != width) {
17231829 needsRecalculateConstraints = true ;
17241830 if (parentData.width != null ) {
@@ -1743,8 +1849,6 @@ class Constraint extends ConstraintDefine {
17431849 needsLayout = true ;
17441850 }
17451851
1746- parentData.clickPadding = clickPadding;
1747-
17481852 if (parentData.visibility != visibility) {
17491853 if (parentData.visibility == gone || visibility == gone) {
17501854 needsLayout = true ;
@@ -1855,8 +1959,6 @@ class Constraint extends ConstraintDefine {
18551959 needsLayout = true ;
18561960 }
18571961
1858- parentData.callback = callback;
1859-
18601962 if (parentData.percentageTranslate != percentageTranslate) {
18611963 parentData.percentageTranslate = percentageTranslate;
18621964 needsPaint = true ;
@@ -2095,6 +2197,7 @@ class _ConstraintRenderBox extends RenderBox
20952197
20962198 late double _width;
20972199 late double _height;
2200+ ConstraintVersion ? _constraintVersion;
20982201
20992202 bool _needsRecalculateConstraints = true ;
21002203 bool _needsReorderPaintingOrder = true ;
@@ -2283,6 +2386,35 @@ class _ConstraintRenderBox extends RenderBox
22832386 }
22842387 }
22852388
2389+ set constraintVersion (ConstraintVersion ? value) {
2390+ if (_constraintVersion == null || value == null ) {
2391+ markNeedsRecalculateConstraints ();
2392+ markNeedsLayout ();
2393+ } else {
2394+ if (_constraintVersion! ._constraintsVersion !=
2395+ value._constraintsVersion) {
2396+ markNeedsRecalculateConstraints ();
2397+ markNeedsLayout ();
2398+ } else {
2399+ if (_constraintVersion! ._layoutVersion != value._layoutVersion) {
2400+ markNeedsLayout ();
2401+ }
2402+ if (_constraintVersion! ._paintingOrderVersion !=
2403+ value._paintingOrderVersion) {
2404+ needsReorderPaintingOrder = true ;
2405+ }
2406+ if (_constraintVersion! ._paintVersion != value._paintVersion) {
2407+ markNeedsPaint ();
2408+ }
2409+ if (_constraintVersion! ._eventOrderVersion !=
2410+ value._eventOrderVersion) {
2411+ needsReorderEventOrder = true ;
2412+ }
2413+ }
2414+ }
2415+ _constraintVersion = value;
2416+ }
2417+
22862418 @override
22872419 void setupParentData (covariant RenderObject child) {
22882420 if (child.parentData is ! _ConstraintBoxData ) {
0 commit comments