maxPositionalArity property
int
get
maxPositionalArity
The number of positional parameters this function can accept — required and optional together.
Distinct from arity, which counts only the required positional
parameters. For (Object e, [StackTrace? st]) arity is 1 while this is
2, and the difference matters whenever a caller must decide how many
arguments to supply: native Dart passes both arguments to that closure,
because Function(Object, [StackTrace]) is a subtype of
Function(Object, StackTrace). Selecting on arity would drop the second
argument for the optional form. See errorHandlerArgs.
Implementation
int get maxPositionalArity {
final params = _parameters?.parameters;
if (params == null) return 0;
return params.where((p) {
if (p is SSimpleFormalParameter) return p.isPositional;
if (p is SDefaultFormalParameter) return p.isPositional;
if (p is SFieldFormalParameter) {
return true; // this.x params are positional
}
if (p is SSuperFormalParameter) {
return true; // super.x params are positional
}
if (p is SFunctionTypedFormalParameter) return true;
return false;
}).length;
}