Skip to main content

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 two or more positional parameters of type bool.

A function with multiple positional Boolean parameters can be a source of ambiguity at call sites because the purpose of the specified Boolean values might not be clear from the values alone. Named parameters make their intent explicit.

Example

#

The following code produces this diagnostic because the function f has two positional parameters with a type of bool:

dart
void f(bool a, bool b) {}

Common fixes

#

Convert all of the positional parameters to be named parameters (possibly excepting one):

dart
void f(bool a, {bool b = false}) {}