Skip to main content

prefer-use-prefix

added in: 1.12.0
Pro+

Suggests renaming hooks to start with use.

Example

❌ Bad:

// LINT: Hook names are expected to start with 'use'. Try renaming this declaration.
String myCustomHook() {
useMemoized(() {
...
}, []);
}

class MyWidget extends HookWidget {
// LINT: Hook names are expected to start with 'use'. Try renaming this declaration.
void _myPrivateHook() {
useMemoized(() {
...
}, keys);
}
}

✅ Good:

String useCustomHook() {
useMemoized(() {
...
}, []);
}

class MyWidget extends HookWidget {
void _usePrivateHook() {
useMemoized(() {
...
}, keys);
}
}