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

"Classes as enums" tip is obsolete #19

Open
orevial opened this issue Aug 26, 2022 · 1 comment
Open

"Classes as enums" tip is obsolete #19

orevial opened this issue Aug 26, 2022 · 1 comment

Comments

@orevial
Copy link

orevial commented Aug 26, 2022

Using classes as enum has become obsolete since Dart 2.17, this tip could be removed !

https://github.com/vandadnp/flutter-tips-and-tricks/blob/main/tipsandtricks/classes-as-enums-in-dart/classes-as-enums-in-dart.md

@misterfourtytwo
Copy link

misterfourtytwo commented Jan 27, 2023

also, it could be cleaner done through extension, i.e.

enum AnimalType{ dog, cat, parrot };

extension on AnimalType {
  static const _foodTypes =['meat', 'fish', 'fruit'];
  String get foodType => _foodTypes[index];
}

which could still be useful, if it's some local ui property, specific to current widget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants