avoid_ positional_ boolean_ parameters
Details about the 'avoid_positional_boolean_parameters' diagnostic produced by the Dart analyzer.
'bool' parameters should be named parameters.
Description
#
The analyzer produces this diagnostic when a non-overriding, public
function has a positional parameter of type bool.
Positional boolean parameters can cause ambiguity when the function is invoked because the function of the specified boolean value might not be clear from the value alone. Named parameters make their intent explicit.
Example
#
The following code produces this diagnostic because
the function f has a positional parameter with a type of bool:
void f(bool b) {}
Common fixes
#Convert the positional parameter to a named parameter:
void f({bool b = false}) {}
Unless stated otherwise, the documentation on this site reflects Dart 3.11.0. Report an issue.