prefer-correct-handler-name
- Group
- Style
- Path
lint/style/prefer-correct-handler-name- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 338 of 512
Match callback handler methods to a configured regular expression.
Nonempty valid regex name-pattern enables the rule. ignore-public
(default false) exempts public methods. Direct method tear-offs passed as
positional or named arguments are checked, including unqualified references
unless shadowed by a lexical binding. Only ordinary unannotated methods
declared on an enclosing class without supertypes are checked. Global
functions, arbitrary object methods and closure wrappers are excluded.
Leading privacy underscores are ignored.
Invalid
void listen({required void Function() onTap}) {}
void consume(void Function() callback) {}
class Controller {
void tap() {}
void work() {}
void positionalWork() {}
void install() {
listen(onTap: this.tap);
listen(onTap: this.tap);
listen(onTap: work);
consume(positionalWork);
}
}class Controller { void tap() {} void tap() {} void work() {} void work() {} void positionalWork() {}Valid
void listen({required void Function() onTap}) {}
void consume(void Function() callback) {}
void globalWork() {}
class Controller {
void _handleTap() {}
void ordinaryMethod() {}
void install(void Function() ordinaryMethod) {
listen(onTap: this._handleTap);
consume(this._handleTap);
listen(onTap: () {});
listen(onTap: ordinaryMethod);
consume(globalWork);
}
}
class Child extends Controller {
void ordinaryMethod() {}
void wire() { listen(onTap: this.ordinaryMethod); }
}
abstract class HandlerContract {
void tap();
}
class HandlerImplementation implements HandlerContract {
void tap() {}
void wire() { listen(onTap: tap); }
}Configure prefer-correct-handler-name
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"prefer-correct-handler-name": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/prefer-correct-handler-name: <reason>More style rules
- prefer-correct-identifier-length
prefer-correct-identifier-lengthFlags declared identifiers that are shorter or longer than the allowed range.
- prefer-correct-notifier-file-nameriverpod
Requires
snake_casefile names ending in _notifier.dart for resolved Riverpod notifier classes. - prefer-correct-provider-file-nameriverpod
Requires
snake_casefile names ending in _provider.dart for resolved Riverpod provider declarations, including annotated generator functions. - prefer-correct-test-file-nametest
Requires entry-point files under package-root test/ or
integration_test/ to use the _test.dart suffix. - prefer-correct-type-name
prefer-correct-type-nameFlags type declarations whose name is not well-formed
UpperCamelCase. - prefer-dedicated-media-query-methods
prefer_dedicated_media_query_methodsrecommendedflutterFlags
MediaQuery.of(context).sizeaccess in favor ofMediaQuery.sizeOf. - prefer-double-quotes
prefer_double_quotesFlags single-quoted string literals that could use double quotes without needing an escape.
- prefer-early-return
Flags a trailing
ifthat wraps multiple statements in a void function.