flutter-tips-and-tricks
flutter-tips-and-tricks copied to clipboard
"Classes as enums" tip is obsolete
trafficstars
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
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.