vandadnp / flutter-tips-and-tricks

A Collection of Flutter and Dart Tips and Tricks

Home Page:https://linktr.ee/vandadnp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Classes as enums" tip is obsolete

orevial opened this issue · comments

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.