I am trying to use new feature in dart 3.3 – Extension types. Simple example from 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.
}
but in the word type there is an arror:
This requires the 'inline-class' language feature to be enabled.
My flutter version:
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
I was trying to add in pubspec.yaml:
analyzer:
enable-experiment:
- inline-class
Not working. Thanks in advance for the tips.
>Solution :
The full error message actually tells you what to do
This requires the ‘inline-class’ language feature to be enabled.
Try updating your pubspec.yaml to set the minimum SDK constraint to 3.3.0 or higher, and running ‘pub get’.
So, if you maybe have this in your pubspec.yaml
sdk: ">=3.0.0 <4.0.0"
change it to
sdk: ">=3.3.0 <4.0.0"
