avoid-misused-hooks
Warns when hooks are used in non-hook widgets.
Example
❌ Bad:
class SomeWidget extends StatelessWidget {
const SomeWidget();
Widget build(BuildContext context) {
useMemoized(() => {}, keys); // LINT: Avoid using hooks in non-hook widgets.
return Container();
}
}
✅ Good:
class SomeHookWidget extends HookWidget {
const SomeHookWidget();
Widget build(BuildContext context) {
useMemoized(() => {}, keys); // Correct, the widget is a 'HookWidget'
return Container();
}
}