@@ -37,6 +37,7 @@ class ConstraintLayout extends MultiChildRenderObjectWidget {
3737 final bool debugCheckDependencies;
3838 final bool releasePrintLayoutTime;
3939 final String ? debugName;
40+ final bool debugShowZIndex;
4041
4142 ConstraintLayout ({
4243 Key ? key,
@@ -49,6 +50,7 @@ class ConstraintLayout extends MultiChildRenderObjectWidget {
4950 this .debugCheckDependencies = true ,
5051 this .releasePrintLayoutTime = false ,
5152 this .debugName,
53+ this .debugShowZIndex = false ,
5254 }) : super (key: key, children: children);
5355
5456 @override
@@ -61,7 +63,8 @@ class ConstraintLayout extends MultiChildRenderObjectWidget {
6163 ..debugPrintLayoutTime = debugPrintLayoutTime
6264 ..debugCheckDependencies = debugCheckDependencies
6365 ..releasePrintLayoutTime = releasePrintLayoutTime
64- ..debugName = debugName;
66+ ..debugName = debugName
67+ ..debugShowZIndex = debugShowZIndex;
6568 }
6669
6770 @override
@@ -77,7 +80,8 @@ class ConstraintLayout extends MultiChildRenderObjectWidget {
7780 ..debugPrintLayoutTime = debugPrintLayoutTime
7881 ..debugCheckDependencies = debugCheckDependencies
7982 ..releasePrintLayoutTime = releasePrintLayoutTime
80- ..debugName = debugName;
83+ ..debugName = debugName
84+ ..debugShowZIndex = debugShowZIndex;
8185 }
8286}
8387
@@ -399,6 +403,7 @@ class _ConstraintRenderBox extends RenderBox
399403 bool ? _debugCheckDependencies;
400404 bool ? _releasePrintLayoutTime;
401405 String ? _debugName;
406+ bool ? _debugShowZIndex;
402407
403408 final Map <RenderBox , _NodeDependency > _nodeDependencies = HashMap ();
404409 final Map <String , _NodeDependency > _tempNodeDependencies = HashMap ();
@@ -459,6 +464,13 @@ class _ConstraintRenderBox extends RenderBox
459464 }
460465 }
461466
467+ set debugShowZIndex (bool value) {
468+ if (_debugShowZIndex != value) {
469+ _debugShowZIndex = value;
470+ markNeedsPaint ();
471+ }
472+ }
473+
462474 @override
463475 void setupParentData (covariant RenderObject child) {
464476 if (child.parentData is ! _ConstraintBoxData ) {
@@ -646,9 +658,10 @@ class _ConstraintRenderBox extends RenderBox
646658 _nodeDependencies.clear ();
647659 _tempNodeDependencies.clear ();
648660 RenderBox ? child = firstChild;
649- int childIndex = 0 ;
661+ int childIndex = - 1 ;
650662
651663 while (child != null ) {
664+ childIndex++ ;
652665 _ConstraintBoxData childParentData =
653666 child.parentData as _ConstraintBoxData ;
654667
@@ -755,7 +768,6 @@ class _ConstraintRenderBox extends RenderBox
755768 currentNode.bottomDependencyType = 1 ;
756769 }
757770
758- childIndex++ ;
759771 child = childParentData.nextSibling;
760772 }
761773
@@ -1196,7 +1208,9 @@ class _ConstraintRenderBox extends RenderBox
11961208 Offset offset,
11971209 ) {
11981210 RenderBox ? child = firstChild;
1211+ int childIndex = - 1 ;
11991212 while (child != null ) {
1213+ childIndex++ ;
12001214 _ConstraintBoxData childParentData =
12011215 child.parentData as _ConstraintBoxData ;
12021216 if (childParentData.visibility == CL .gone ||
@@ -1241,6 +1255,25 @@ class _ConstraintRenderBox extends RenderBox
12411255 return true ;
12421256 }());
12431257
1258+ // draw child's z index
1259+ assert (() {
1260+ if (_debugShowZIndex == true ) {
1261+ ui.ParagraphBuilder paragraphBuilder =
1262+ ui.ParagraphBuilder (ui.ParagraphStyle (
1263+ textAlign: TextAlign .center,
1264+ fontSize: 10 ,
1265+ ));
1266+ paragraphBuilder.addText ("z-index $childIndex " );
1267+ ui.Paragraph paragraph = paragraphBuilder.build ();
1268+ paragraph.layout (ui.ParagraphConstraints (
1269+ width: child! .size.width,
1270+ ));
1271+ context.canvas
1272+ .drawParagraph (paragraph, (childParentData.offset + offset));
1273+ }
1274+ return true ;
1275+ }());
1276+
12441277 child = childParentData.nextSibling;
12451278 }
12461279 }
0 commit comments