Is it possible to create enum with arguments. For example in Kotlin I can do something like this:
enum class TestType(val testText: String, val number: Int) {
STATIC("", 0),
DYNAMIC("", 1)
}
And each enum item contains testText and number. Is it possible to implement this in the Dart programming language. Please help me.
CodePudding user response:
Not possible in current version of Dart but it is something being actively worked on. It is still too early to say when this feature are done but the specification is completed, so the missing part is the implementation of the feature:
https://github.com/dart-lang/language/issues/158
https://github.com/dart-lang/sdk/issues/47849
CodePudding user response:
You can certainly build one with an ordinary class and a lot of static const for the values. The only thing you'll be missing from a proper enum is ensuring all cases are covered in a switch.