这需要启用 'enhanced-enums' 语言功能
This requires the 'enhanced-enums' language feature to be enabled
我刚刚升级了我的 Flutter SDK,但我仍然无法使用增强型枚举。
$ dart --version
打印
Dart SDK version: 2.18.0-109.0.dev
这是我的代码:
enum Foo {
bar(0),
baz(1),
final int i;
const Foo(this.i);
}
我收到以下错误:
This requires the 'enhanced-enums' language feature to be enabled.
Expected to find '}'.
这里有两个问题。
更新 pubspec.yaml
文件中的 Dart SDK 版本限制以使用新的 Dart 2.17.0
版本
environment:
sdk: ">=2.17.0 <3.0.0"
然后运行flutter pub get
命令
您的枚举必须以分号结束 ;
而不是逗号 ,
enum Foo {
bar(0),
baz(1); // <-- Replaced "," with ";"
final int i;
const Foo(this.i);
}
我刚刚升级了我的 Flutter SDK,但我仍然无法使用增强型枚举。
$ dart --version
打印
Dart SDK version: 2.18.0-109.0.dev
这是我的代码:
enum Foo {
bar(0),
baz(1),
final int i;
const Foo(this.i);
}
我收到以下错误:
This requires the 'enhanced-enums' language feature to be enabled.
Expected to find '}'.
这里有两个问题。
更新
pubspec.yaml
文件中的 Dart SDK 版本限制以使用新的 Dart2.17.0
版本environment: sdk: ">=2.17.0 <3.0.0"
然后运行
flutter pub get
命令您的枚举必须以分号结束
;
而不是逗号,
enum Foo { bar(0), baz(1); // <-- Replaced "," with ";" final int i; const Foo(this.i); }