prefer_underscore_for_unused_callback_parameters

SeverityQuick FixOptions
Info

Details

DO use _ for unused callback parameters.

Since Dart 3.7.0, local parameters named _ can be declared multiple times without collisions.

see: effective-dart and wildcard variables

Bad
itemBuilder: (context, index) {
  return Text('Item $index');
}
Good
itemBuilder: (_, index) {
  return Text('Item $index');
}

Usage

To enable the prefer_underscore_for_unused_callback_parameters rule, add prefer_underscore_for_unused_callback_parameters under custom_lint > rules in your analysis_options.yaml file:

custom_lint:
  rules:
    - prefer_underscore_for_unused_callback_parameters