@@ -1591,6 +1591,26 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
1591
1591
static RenderObject ? get debugActiveLayout => _debugActiveLayout;
1592
1592
static RenderObject ? _debugActiveLayout;
1593
1593
1594
+ /// Set [debugActiveLayout] to null when [inner] callback is called.
1595
+ /// This is useful when you have to temporarily clear that variable to
1596
+ /// disable some false-positive checks, such as when computing toStringDeep
1597
+ /// or using custom trees.
1598
+ @pragma ('vm:prefer-inline' )
1599
+ static T _withDebugActiveLayoutCleared <T >(T Function () inner) {
1600
+ RenderObject ? debugPreviousActiveLayout;
1601
+ assert (() {
1602
+ debugPreviousActiveLayout = _debugActiveLayout;
1603
+ _debugActiveLayout = null ;
1604
+ return true ;
1605
+ }());
1606
+ final T result = inner ();
1607
+ assert (() {
1608
+ _debugActiveLayout = debugPreviousActiveLayout;
1609
+ return true ;
1610
+ }());
1611
+ return result;
1612
+ }
1613
+
1594
1614
/// Whether the parent render object is permitted to use this render object's
1595
1615
/// size.
1596
1616
///
@@ -3399,22 +3419,11 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
3399
3419
String ? prefixOtherLines = '' ,
3400
3420
DiagnosticLevel minLevel = DiagnosticLevel .debug,
3401
3421
}) {
3402
- RenderObject ? debugPreviousActiveLayout;
3403
- assert (() {
3404
- debugPreviousActiveLayout = _debugActiveLayout;
3405
- _debugActiveLayout = null ;
3406
- return true ;
3407
- }());
3408
- final String result = super .toStringDeep (
3409
- prefixLineOne: prefixLineOne,
3410
- prefixOtherLines: prefixOtherLines,
3411
- minLevel: minLevel,
3412
- );
3413
- assert (() {
3414
- _debugActiveLayout = debugPreviousActiveLayout;
3415
- return true ;
3416
- }());
3417
- return result;
3422
+ return _withDebugActiveLayoutCleared (() => super .toStringDeep (
3423
+ prefixLineOne: prefixLineOne,
3424
+ prefixOtherLines: prefixOtherLines,
3425
+ minLevel: minLevel,
3426
+ ));
3418
3427
}
3419
3428
3420
3429
/// Returns a one-line detailed description of the render object.
@@ -3427,18 +3436,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
3427
3436
String joiner = ', ' ,
3428
3437
DiagnosticLevel minLevel = DiagnosticLevel .debug,
3429
3438
}) {
3430
- RenderObject ? debugPreviousActiveLayout;
3431
- assert (() {
3432
- debugPreviousActiveLayout = _debugActiveLayout;
3433
- _debugActiveLayout = null ;
3434
- return true ;
3435
- }());
3436
- final String result = super .toStringShallow (joiner: joiner, minLevel: minLevel);
3437
- assert (() {
3438
- _debugActiveLayout = debugPreviousActiveLayout;
3439
- return true ;
3440
- }());
3441
- return result;
3439
+ return _withDebugActiveLayoutCleared (() => super .toStringShallow (joiner: joiner, minLevel: minLevel));
3442
3440
}
3443
3441
3444
3442
@protected
0 commit comments