Skip to main content

avoid-misused-hooks

added in: 1.17.0

Warns when hooks are used in non-hook widgets.

Example

❌ Bad:

class SomeWidget extends StatelessWidget {
const SomeWidget();


Widget build(BuildContext context) {
useMemoized(() => {}, keys); // LINT

return Container();
}
}

✅ Good:

class SomeHookWidget extends HookWidget {
const SomeHookWidget();


Widget build(BuildContext context) {
useMemoized(() => {}, keys);

return Container();
}
}