Skip to main content

avoid-shadowed-extension-methods

added in: 1.7.0
Pro+
preset: recommended

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 {
void split(String pattern) {} // LINT
}

✅ Good:

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