Here’s a nice simple article explaining enhanced enums that have been around for a while but may be something overlooked. Between these and sealed classes I think Dart has an excellent story for pattern matching.

  • anlumo@feddit.de
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    I’ve yet to find a single use case for enhanced enums. It also doesn’t help that freezed doesn’t support them.

    • Rexios@lemm.ee
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      How exactly does freezed not support them? All data on an enhanced enum is static.

        • Rexios@lemm.ee
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          I’m not sure enhanced enums do what you think they do if you expect freezed to generate anything for them besides what json_serializable generates for regular enums

          • anlumo@feddit.de
            link
            fedilink
            English
            arrow-up
            0
            ·
            1 year ago

            The whole point of the discussion is that enhanced enums don’t do anything in practice.