Skip to content

BenjaminMahmic/dart_enum_extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

Dart enum Extension

Easy Dart Enum

Made by Benjamin Mahmić ("https://github.com/BenjaminMahmic")

Extension link: "https://marketplace.visualstudio.com/items?itemName=BenjaminMahmic.easy-dart-enum"

How to use

  1. Select complete enum

Screenshot_1

  1. Call Quick Fix (Windows: Ctrl + . or Mac: ⌘ + .) and select Generate (is)Enum Extension

Screenshot_2

  1. That's it! 🎉

Screenshot_3

Example

  enum SubscriptionType {
    free,
    monthly,
    annal,
  }

  extension SubscriptionTypeExtension on SubscriptionType {
    bool get isFree => this == SubscriptionType.free;
    bool get isMonthly => this == SubscriptionType.monthly;
    bool get isAnnual => this == SubscriptionType.annual;
  }

  final subscriptionType = SubscriptionType.monthly;

  void main() {
    print(subscriptionType.isMonthly); // true
    print(subscriptionType.isAnnual); // false
  }

Enjoy! 🚀

About

VSC Extension for Dart (enum)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published