Supposedly Dart 2.14 included the triple shift operator (>>>
), but when I try to use it I get an error:
print(0xff >>> 1);
The compiler highlights the last >
of the three and says:
Expected an identifier.
This is true on my local machine and in DartPad. Both are using the version of Dart 2.14 shipped with Flutter 2.5.
Am I doing something wrong or is this a problem with the release?
You can refer to my related answer here.
Any language features that are introduced in a given version require that version as the minimum constraint for your project. This means you need to update your pubspec.yaml
:
environment:
sdk: '>=2.14.0 <3.0.0'
Now, you can use:
var foo = 42;
foo >>> 2;