Skip to main content

avoid-shadowed-extension-methods

Warns when an extension declares a method with the name that is already used by the extension target.

If the extension target already has a method with the same name, it requires additional hacks to call the method from the extension. Consider renaming the method instead.

Example

❌ Bad:

extension Extension on String {
// LINT: Extension target already declares a member with the same name.
// Try renaming this method.
void split(String pattern) {}
}

✅ Good:

extension Extension on String {
void customSplit(String pattern) {}
}