Alexandre Ardhuin 978a2e7bf6
migrate foundation to nullsafety (#61188)
* migrate foundation to nullsafety

* address review comments
2020-07-15 18:55:27 +02:00

19 lines
744 B
Dart

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