1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | /// Framework code should use this method in favor of calling `toString` on |
6 | /// [Object.runtimeType]. |
7 | /// |
8 | /// Calling `toString` on a runtime type is a non-trivial operation that can |
9 | /// negatively impact performance. If asserts are enabled, this method will |
10 | /// return `object.runtimeType.toString()`; otherwise, it will return the |
11 | /// [optimizedValue], which must be a simple constant string. |
12 | String objectRuntimeType(Object? object, String optimizedValue) { |
13 | assert(() { |
14 | optimizedValue = object.runtimeType.toString(); |
15 | return true; |
16 | }()); |
17 | return optimizedValue; |
18 | } |
19 | |