extension_override_argument_not_assignable
The type of the argument to the extension override '{0}' isn't assignable to the extended type '{1}'.
Description
#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
:
dart
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:
dart
extension E on String {
void method() {}
}
void f() {
E(3.toString()).method();
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。