Skip to main content

undefined_extension_getter

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

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

Description

#

The analyzer produces this diagnostic when a static getter 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 getter named a:

dart
extension E on String {}
​
var x = E.a;

Common fixes

#

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

dart
extension E on String {
  static String get b => 'b';
}
​
var x = E.b;

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

dart
extension E on String {
  static String get a => 'a';
}
​
var x = E.a;