main_is_not_function
The declaration named 'main' must be a function.
Description
#The analyzer produces this diagnostic when a library contains a declaration
of the name main
that isn't the declaration of a top-level function.
Example
#The following code produces this diagnostic because the name main
is
being used to declare a top-level variable:
dart
var main = 3;
Common fixes
#Use a different name for the declaration:
dart
var mainIndex = 3;
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。