Home > Net >  Dart 2.17.0: how do I enable "enhanced-enums"?
Dart 2.17.0: how do I enable "enhanced-enums"?

Time:05-12

Code example:

enum ShareType {
NONE('N'),
PUBLISH('P'),
  SHARE('S');

final String key;
const ShareType(String keyToSet) {this.key = keyToSet;}
}

gives error:

This requires the 'enhanced-enums' language feature to be enabled.

How do I enable this feature? Where must this be set?

CodePudding user response:

Go into your pubspec.yaml file in your project and make sure that the minimum version for the sdk are 2.17.0 like:

environment:
  sdk: ">=2.17.0 <3.0.0"

The reason for this is that Dart keeps track of when features are introduced and makes sure your project does not make use of features that would not be compatible for the range of versions your project have specified as required.

  • Related