extension_override_access_to_static_member
An extension override can't be used to access a static member from an extension.
Description
#The analyzer produces this diagnostic when an extension override is the receiver of the invocation of a static member. Similar to static members in classes, the static members of an extension should be accessed using the name of the extension, not an extension override.
Example
#The following code produces this diagnostic because m
is static:
dart
extension E on String {
static void m() {}
}
void f() {
E('').m();
}
Common fixes
#Replace the extension override with the name of the extension:
dart
extension E on String {
static void m() {}
}
void f() {
E.m();
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。