main_first_positional_parameter_type
The type of the first positional parameter of the 'main' function must be a
supertype of 'List
Description
#The analyzer produces this diagnostic when the first positional parameter
of a function named main
isn't a supertype of List<String>
.
Example
#The following code produces this diagnostic because List<int>
isn't a
supertype of List<String>
:
dart
void main(List<int> args) {}
Common fixes
#If the function is an entry point, then change the type of the first
positional parameter to be a supertype of List<String>
:
dart
void main(List<String> args) {}
If the function isn't an entry point, then change the name of the function:
dart
void f(List<int> args) {}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。