Skip to main content

undefined_extension_method

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

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

Description

#

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

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

Common fixes

#

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

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

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

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