Home > OS >  Strange and unexpected behavior of the constructor of an enum in Dart
Strange and unexpected behavior of the constructor of an enum in Dart

Time:08-21

I’m writing a code with a enum.

You can run the code here in a DartPad.

The enum constructor has a optional named parameter codeAndDescription. An enumeration value does not specify the value of parameter codeAndDescription (which by default should be an empty string). If I print this value, it does not print an empty string, but 'null'. Does anyone know if this is a bug or if I’m wrong?

Thank you very much!

CodePudding user response:

It is a know bug, as mmcdon20 also mention, which have been fixed for the upcoming Dart 2.18 version. This version is right now in beta.

You can find the bug report here: https://github.com/dart-lang/sdk/issues/49216

  • Related