From a1aea2e4423af6136f651455b5f1d74363ce29c4 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 4 Mar 2019 11:05:20 -0800 Subject: [PATCH] Use a simpler implementation of Diagnosticable.toString when running in profile/release mode (#28661) Diagnosticable.toString may be called in performance sensitive contexts (for example, creating debug labels for Tickers) --- packages/flutter/lib/src/foundation/diagnostics.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/foundation/diagnostics.dart b/packages/flutter/lib/src/foundation/diagnostics.dart index dc454762e1..5c0b8127a6 100644 --- a/packages/flutter/lib/src/foundation/diagnostics.dart +++ b/packages/flutter/lib/src/foundation/diagnostics.dart @@ -2127,7 +2127,12 @@ abstract class Diagnosticable { @override String toString({ DiagnosticLevel minLevel = DiagnosticLevel.debug }) { - return toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(minLevel: minLevel); + String fullString; + assert(() { + fullString = toDiagnosticsNode(style: DiagnosticsTreeStyle.singleLine).toString(minLevel: minLevel); + return true; + }()); + return fullString ?? toStringShort(); } /// Returns a debug representation of the object that is used by debugging