Skip to main content

undefined_extension_setter

Details about the 'undefined_extension_setter' diagnostic produced by the Dart analyzer.

The setter '{0}' isn't defined for the extension '{1}'.

Description

#

The analyzer produces this diagnostic when a static setter is referenced, but isn't defined by the specified extension.

Example

#

The following code produces this diagnostic because the extension E doesn't declare a static setter named a:

dart
extension E on String {}
​
void f() {
  E.a = 3;
}

Common fixes

#

If the name of the setter is incorrect, then change it to the name of an existing static setter:

dart
extension E on String {
  static set b(int _) {}
}
​
void f() {
  E.b = 3;
}

If the setter isn't defined, then define it:

dart
extension E on String {
  static set a(int _) {}
}
​
void f() {
  E.a = 3;
}