Skip to main content

avoid-recursive-calls

added in: 1.9.0

Warns when a function calls itself recursively.

Dart does not support tail call optimization, so when working with a recursion there is always a chance to hit a StackOverflow error. Consider rewriting recursion to a stack instead.

Example

❌ Bad:

String some() {
return some(); // LINT
}

✅ Good:

String some() {
return another();
}