avoid-local-functions
Warns when a function declaration is a local function.
Local functions complicate the readability of the containing function by inverting its flow (you see a lot of code at first that will be somehow used later) and can lead to unexpected inclusion of outer scope variables.
Example
❌ Bad:
bool someFunction(String externalValue) {
final value = 'some value';
// LINT
bool isValid() {
// some
// additional
// logic
}
return isValid() && externalValue != value;
}
✅ Good:
bool someFunction(String externalValue) {
final value = 'some value';
return isValid() && externalValue != value;
}
bool isValid() {
// some
// additional
// logic
}