Migration guide for describeEnum
Summary
The global method describeEnum
has been deprecated. Existing uses
of describeEnum(Enum.something)
should use
Enum.something.name
instead.
Context
Dart 2.17 introduced enhanced enums. With them, Enum became a type
and all enums got a name
getter, which made describeEnum
redundant.
The describeEnum
method was used to convert an enum value to a string,
since Enum.something.toString()
would produce Enum.something
instead
of something
, which a lot of users wanted. Now, the name
getter does this.
Description of change
Remove describeEnum
.
- Replace
describeEnum(Enum.something)
withEnum.something.name
.
Migration guide
If you used describeEnum(Enum.field)
to acesss the string value from an
enum, you can now call Enum.field.name
.
Code before migration:
enum MyEnum { paper, rock }
print(describeEnum(MyEnum.paper)); // output: paper
Code after migration:
enum MyEnum { paper, rock }
print(MyEnum.paper.name); // output: paper
Timeline
Landed in version: TBD
In stable release: not yet
References
API documentation:
Relevant issues:
Relevant PRs: