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

Use external class directly without wrapping #29

Closed passsy closed 4 years ago

passsy commented 4 years ago

Sometimes I share classes between multiple superEnums. This is currently only possible by wrapping them each time I use them.

class ApiError { /*...*/ }

@superEnum
enum _ResultA {
  @Data(fields: [
    DataField('error', ApiError),
  ])
  Error,
}

@superEnum
enum _ResultB {
  @Data(fields: [
    DataField('error', ApiError),
  ])
  Error,
}

I'd prefer to use some classes directly without having them auto-generated and wrapped.

class ApiError { /*...*/ }

@superEnum
enum _ResultA {
  @UserClass(ApiError)
  Error,
}

@superEnum
enum _ResultB {
  @UserClass(ApiError)
  Error,
}
astralstriker commented 4 years ago

I will check the feasibility of this and get back to you. Can you suggest a usecase for this feature? I can't really think of one

astralstriker commented 4 years ago

Office work has rendered us unable work on other projects these days. It will remain the same for the next few days as well. Would you like to implement this feature, if this is feasible in the first place, and submit a pull request?