prefer-void-callback
- Group
- Style
- Path
lint/style/prefer-void-callback- Default
- Off, opt in
- Origin
- Falcon
- Domain
- flutter
- Rule
- 420 of 512
Prefers Flutter's VoidCallback alias over a nongeneric void Function() type.
Import VoidCallback from package:flutter/foundation.dart and use
VoidCallback? for nullable callbacks. Functions with parameters, type
parameters, or a non-void return type are not covered.
Invalid
void invoke(void Function() callback) => callback();
void Function()? callback;
typedef Handler = void Function();void invoke(void Function() callback) => callback();void invoke(void Function() callback) => callback();void Function()? callback;void Function()? callback;typedef Handler = void Function();Valid
VoidCallback? callback;
void takesArgument(void Function(int) callback) {}
void returnsValue(int Function() callback) {}
void generic(void Function<T>() callback) {}
typedef void Legacy();Configure prefer-void-callback
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"prefer-void-callback": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/prefer-void-callback: <reason>More style rules
- provide-deprecation-message
provide_deprecation_messagerecommendedFlags
@deprecatedand@Deprecated()annotations that carry no message. - public-member-api-docs
public_member_api_docsDocuments public declarations and members in package libraries.
- record-fields-ordering
Flags named record type fields that violate the configured order.
- require-trailing-commas
require_trailing_commasFlags a multi-line call, declaration, assert, or collection literal that is missing a trailing comma.
- sized-box-shrink-expand
sized_box_shrink_expandrecommendedflutterPrefers
SizedBox.shrink()/SizedBox.expand()over aSizedBoxsized to zero or infinity. - slash-for-doc-comments
slash_for_doc_commentsrecommendedFlags
/** ... - sort-child-properties-last
sort_child_properties_lastrecommendedflutterSort Widget-valued child properties last, except before closure arguments.
- sort-constructors-first
sort_constructors_firstFlags a constructor declared after a non-constructor member.