EN_raw_main_has_too_many_required_positional_parameters
-
Toolschevron_right -
Diagnosticschevron_right -
main_has_too_many_required_positional_parameters main_has_too_many_required_positional_parameters Details about the 'main_has_too_many_required_positional_parameters' diagnostic produced by the Dart analyzer. more_vert -
copyCopy link -
bug_reportReport issue
The function 'main' can't have more than two required positional parameters.
Description
#
The analyzer produces this diagnostic when a function named `main` has more
than two required positional parameters.
Example
#
The following code produces this diagnostic because the function `main` has
three required positional parameters:
dart
void main(List<String> args, int x, int y) {}
content_copy
Common fixes
#
If the function is an entry point and the extra parameters aren't used,
then remove them:
dart
void main(List<String> args, int x) {}
content_copy
If the function is an entry point, but the extra parameters used are for
when the function isn't being used as an entry point, then make the extra
parameters optional:
dart
void main(List<String> args, int x, [int y = 0]) {}
content_copy
If the function isn't an entry point, then change the name of the function:
dart
void f(List<String> args, int x, int y) {}
content_copy
Was this page's content helpful?
thumb_up
thumb_down
Unless stated otherwise, the documentation on this site reflects Dart 3.13.3. Report an issue.