我正在try 使用DART 3.3中的新功能-扩展类型.doc个简单的例子:
extension type IdNumber(int id) {
// Wraps the 'int' type's '<' operator:
operator <(IdNumber other) => id < other.id;
// Doesn't declare the '+' operator, for example,
// because addition does not make sense for ID numbers.
}
但在单词type
中有一个错误:
This requires the 'inline-class' language feature to be enabled.
个
我的Flutter版本:
Flutter 3.19.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision bae5e49bc2 (6 days ago) • 2024-02-13 17:46:18 -0800
Engine • revision 04817c99c9
Tools • Dart 3.3.0 • DevTools 2.31.1
我试图在pubspec.yaml中添加以下内容,但它不起作用:
analyzer:
enable-experiment:
- inline-class