main_has_required_named_parameters
The function 'main' can't have any required named parameters.
Description
#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
):
dart
void main({required int x}) {}
Common fixes
#If the function is an entry point, then remove the required
keyword:
dart
void main({int? x}) {}
If the function isn't an entry point, then change the name of the function:
dart
void f({required int x}) {}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。