Skip to content

Files

Latest commit

 

History

History
34 lines (24 loc) · 780 Bytes

unreachable_from_main.md

File metadata and controls

34 lines (24 loc) · 780 Bytes

Pattern: Unreachable from main

Issue: -

Description

Top-level members in an executable library should be used directly inside this library. An executable library is a library that contains a main top-level function or that contains a top-level function annotated with @pragma('vm:entry-point'). Executable libraries are not usually imported and it's better to avoid defining unused members.

This rule assumes that an executable library isn't imported by other files except to execute its main function.

Example of incorrect code:

main() {}
void f() {}

Example of correct code:

main() {
 f();
}
void f() {}

Further Reading