Error: "redeclare" annotation is undefined -Dart

24 Views Asked by At

I'm trying to use 'redeclare' annotation inside extension type in dart

extension type MyString(String _) implements String {
  // Replaces 'String.operator[]'
  @redeclare
  int operator [](int index) => codeUnitAt(index);
}

but it give me this error

Undefined name 'redeclare' used as an annotation. Try defining the name or importing it from another library.

Any idea how I can fix the problem ?

The sdk version in my device: Dart SDK version: 3.3.0 (stable)

0

There are 0 best solutions below