EN_raw_main_is_not_function

  •                   Toolschevron_right
    
  •                   Diagnosticschevron_right
    
  •                   main_is_not_function
    
                main_is_not_function
    

Details about the 'main_is_not_function' diagnostic produced by the Dart analyzer.

                more_vert
  •                       copyCopy link
    
  •                       bug_reportReport issue
    

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;
                content_copy

              Common fixes

              #

Use a different name for the declaration:

                dart
var mainIndex = 3;
                content_copy

Was this page's content helpful?

                    thumb_up
                    thumb_down

                Unless stated otherwise, the documentation on this site reflects Dart 3.13.3. Report an issue.