xsahil03x / super_enum

Create super-powered dart enums similar to sealed classes in Kotlin
https://pub.dev/packages/super_enum
MIT License
116 stars 13 forks source link

Enum as data field in another enum #37

Closed fdietze closed 4 years ago

fdietze commented 4 years ago

I'm trying to do this:

@superEnum
enum _SelectedContact {
  @Data(fields: [DataField('user', User)])
  InternalUser,

  @Data(fields: [DataField('contact', Contact)])
  AddressBook,
}

Where Contact is another super enum defined in a different file. When building this, the generated file only contains the following comment, and no code:

/*FormatException: Not an instance of Type.*/

Is reusing enums in other enums not allowed?

passsy commented 4 years ago

I ran myself into this problem as well. It's currently not supported but it could be in the future.

One way to solve this is to use the @UseClass annotation and create the classes yourself