Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow generating enums as Dart enums #1903

Open
stuartmorgan opened this issue Jan 15, 2025 · 0 comments
Open

Allow generating enums as Dart enums #1903

stuartmorgan opened this issue Jan 15, 2025 · 0 comments

Comments

@stuartmorgan
Copy link

(See previous discussion in #1816)

I have this Java declaration in a class:

  public enum StreamingFormat {
    /** Default, if the format is either not known or not another valid format. */
    UNKNOWN,

    /** Smooth Streaming. */
    SMOOTH,

    /** MPEG-DASH (Dynamic Adaptive over HTTP). */
    DYNAMIC_ADAPTIVE,

    /** HTTP Live Streaming (HLS). */
    HTTP_LIVE
  }

The resulting generated code is a class with getters like:

  static VideoAsset$StreamingFormat? get DYNAMIC_ADAPTIVE =>
      _id_DYNAMIC_ADAPTIVE.get(
          _class, const $VideoAsset$StreamingFormat$NullableType());

Because i's a bag of statics rather than an enum, very useful features like compiler-enforced exhaustive switch statements don't work. It sounds from comments in the other issue like there may be cases where clients could need to treat the enum as a class for Java compat, but for use cases where that's not necessary it would be a better dev experience to generate Dart enums, so a config option for that could be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants