7

How to encode Algebraic Data Types current in Dart?

Algebraic data types are also known as:

Question is, how do I implement it in current Dart / Flutter, given that support for it has not landed yet (see issue #349)?

There are some approaches explained on the internet, e.g. I've found the match library, the sealed_unions library, the if-else approach, and some more trickier techniques.

But I'd really love some more expert opinions on what to choose, and why did you chose it. Thoughts?

VasiliNovikov
  • 9,681
  • 4
  • 44
  • 62
  • https://pub.dev/packages/freezed#unionssealed-classes – Pavel Apr 24 '21 at 21:22
  • This is now something the Dart team is actively building: https://github.com/dart-lang/language/issues/546#issuecomment-1315890650 (The question remains relevant — at least for now — but hopefully that's a useful pointer for some folks coming across it.) – Greg Price Dec 18 '22 at 00:41

0 Answers0