main_
                  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:
                  
var main = 3;
Common fixes
#Use a different name for the declaration:
var mainIndex = 3;
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.