From 6da6fbf5a8f18f84d7888d0e5f60808bd77decaf Mon Sep 17 00:00:00 2001 From: Bernardo Ferrari Date: Wed, 9 Aug 2023 18:58:52 -0300 Subject: [PATCH] Deprecate `describeEnum`. (#125016) Final part of https://github.com/flutter/flutter/issues/123346. --- .../flutter/lib/src/foundation/diagnostics.dart | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/flutter/lib/src/foundation/diagnostics.dart b/packages/flutter/lib/src/foundation/diagnostics.dart index e5c1345ade..b2ecd9a903 100644 --- a/packages/flutter/lib/src/foundation/diagnostics.dart +++ b/packages/flutter/lib/src/foundation/diagnostics.dart @@ -2262,14 +2262,12 @@ class IterableProperty extends DiagnosticsProperty> { } } -/// An property than displays enum values tersely. +/// [DiagnosticsProperty] that has an [Enum] as value. /// -/// The enum value is displayed with the class name stripped. For example: +/// The enum value is displayed with the enum name stripped. For example: /// [HitTestBehavior.deferToChild] is shown as `deferToChild`. /// -/// This class can be used with classes that appear like enums but are not -/// "real" enums, so long as their `toString` implementation, in debug mode, -/// returns a string consisting of the class name followed by the value name. It +/// This class can be used with enums and returns the enum's name getter. It /// can also be used with nullable properties; the null value is represented as /// `null`. /// @@ -2277,7 +2275,7 @@ class IterableProperty extends DiagnosticsProperty> { /// /// * [DiagnosticsProperty] which documents named parameters common to all /// [DiagnosticsProperty]. -class EnumProperty extends DiagnosticsProperty { +class EnumProperty extends DiagnosticsProperty { /// Create a diagnostics property that displays an enum. /// /// The [level] argument must also not be null. @@ -2293,7 +2291,7 @@ class EnumProperty extends DiagnosticsProperty { if (value == null) { return value.toString(); } - return describeEnum(value!); + return value!.name; } } @@ -2975,11 +2973,16 @@ String describeIdentity(Object? object) => '${objectRuntimeType(object, '