Dart Analyze logoDart Analyze/
DRT-W1350

Extension override argument is not assignableDRT-W1350

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when the argument to an extension override isn't assignable to the type being extended by the extension.

Example

The following code produces this diagnostic because 3 isn't a String:

extension E on String {
  void method() {}
}

void f() {
  E(3).method();
}

Common fixes

If you're using the correct extension, then update the argument to have the correct type:

extension E on String {
  void method() {}
}

void f() {
  E(3.toString()).method();
}

If there's a different extension that's valid for the type of the argument, then either replace the name of the extension or unwrap the argument so that the correct extension is found.