Dart Analyze logoDart Analyze/
DRT-W1462

The function 'main' can't have any required named parametersDRT-W1462

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when a function named main has one or more required named parameters.

Example

The following code produces this diagnostic because the function named main has a required named parameter (x):

void main({required int x}) {}

Common fixes

If the function is an entry point, then remove the required keyword:

void main({int? x}) {}

If the function isn't an entry point, then change the name of the function:

void f({required int x}) {}