Closed
Description
Flutter can't use the default toString()
for enum types as it is too verbose and instead has to carefully call a describeEnum(entry)
helper whenever an enum entry is displayed in a message.
The describeEnum helper strips out the enum type from the result of calling entry.toString()
.
It would be nice if the default toString() for enum just displayed the enum value or if the enum class provided a toStringShort()
method that returned just the enum value.
Note that you someone who really wanted to display Type.entry could just write
'${entry.runtimeType}.${entry}'
Example of current behavior:
enum Day {
monday, tuesday, wednesday, thursday, friday, saturday, sunday
}
main() {
assert(Day.monday.toString() == 'Day.monday');
assert(describeEnum(Day.monday) == 'monday');
}