4 ms·
Last I checked you can’t even have enums with payloads/ associated values. Garbage language
by newZWhoDis 4y ago
Last I checked you can’t even have enums with payloads/ associated values.
Garbage language
- strongpigeon 4y agoYou can since 2.17. Not sure if you’re being sarcastic about this making it a garbage language.
- newZWhoDis 4y agoIs that not just string/int/basic types? Last time I looked it was and it was a complete joke. I want to define enum UserState { case loggedOut case loggedIn(user: User) } where User is itself a struct with props like email/id/Etc Then, I want to be able to switch on said enum, so that my code can take a UserSession state stream and switch over each case to react accordingly. This gives me compiler - enforced case handling completeness everywhere my enum is consumed which is amazing for code reliability. This is trivial in Swift or any real language, but with Dart and the stupid flutter bloc model you seemingly can’t do this and end up with these huge if cast chains to send messages. If I’m wrong and things have changed for the better please let me know, it was my biggest issue with dart/flutter
- munificent 4y agohttps://codewithandrea.com/tips/enums-with-members-dart-2.17 https://codewithandrea.com/tips/enums-with-members-dart-2.17
- newZWhoDis 4y agoSee my sibling comment. That appears to only work with basic types like strings/ints? I need to add complex objects, sometimes multiple. Swift lets you do this easily.
- munificent 4y agoNo, you can add as many fields of whatever types you want to an enum in Dart.