22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5+ /// Whether [_debugPrint] is printing to stdout.UnsupportedError
6+ ///
7+ /// Change this to `false` during development/debugging to temporarily disable
8+ /// the debug printing without having to remove calls to [debugPrint] ,
9+ /// [debugPrintStart] , [debugPrintEnd] and [inDebugPrint] .
10+ const bool _debugPrintEnabled = true ;
11+
12+ /// The current indentation level used in [_debugPrint] .
513int _indentLevel = 0 ;
614
715/// Prints the `toString()` of [value] to stdout.
@@ -12,15 +20,15 @@ void debugPrint(Object value) {
1220 _debugPrint (value);
1321}
1422
15- /// Prints the `toString()` of [value] using [debugPrint] and increases the
16- /// indentation level used by [debugPrint] .
23+ /// Decreases the indentation level used by [debugPrint] and prints the
24+ /// `toString()` of [value] using [debugPrint] .
1725void debugPrintEnd (Object value) {
1826 _indentLevel-- ;
1927 _debugPrint (value);
2028}
2129
22- /// Decreases the indentation level used by [debugPrint] and prints the
23- /// `toString()` of [value] using [debugPrint] .
30+ /// Prints the `toString()` of [value] using [debugPrint] and increases the
31+ /// indentation level used by [debugPrint] .
2432void debugPrintStart (Object value) {
2533 _debugPrint (value);
2634 _indentLevel++ ;
@@ -40,6 +48,10 @@ void inDebugPrint(Object value, void Function() f) {
4048 }
4149}
4250
51+ /// Prints the `toString()` of [value] at the current [_indentLevel] if
52+ /// [_debugPrintEnabled] is `true` .
4353void _debugPrint (Object value) {
44- print ('${' ' * _indentLevel }${value }' );
54+ if (_debugPrintEnabled) {
55+ print ('${' ' * _indentLevel }${value }' );
56+ }
4557}
0 commit comments