this post was submitted on 04 Oct 2023
1 points (66.7% liked)

Flutter

754 readers
1 users here now

Flutter and the related logo are trademarks of Google LLC. We are not endorsed by or affiliated with Google LLC

founded 2 years ago
MODERATORS
 

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.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 2 years ago (7 children)

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

[–] [email protected] 1 points 2 years ago

Prior to sealed classes, I wished they were more like swift enums that could carry dynamic data and have different associated types per case. Now if I want that, I can do that with a sealed class. It’s still nice to have smarter enums if I need a little extra smarts and want to keep the logic close to the enum.

load more comments (6 replies)