avoid-conditional-hooks
Warns when hooks inside the build method or other hooks are called conditionally.
Example
❌ Bad:
void useOtherFunction(bool condition) {
// LINT
final b = condition ? useMemoized(() {}) : useMemoized(() {});
}
class MyWidget extends HookWidget {
Widget build() {
var condition = true;
if (condition) {
useMemoized(() {}); // LINT
}
...
}
}
✅ Good:
class MyWidget extends HookWidget {
Widget build() {
useMemoized(() {
if (condition) {
...
}
});
...
}
}