unreachable_from_main
Unreachable top-level members in executable libraries.
This rule is available as of Dart 2.19.0.
Details
Top-level members and static 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.
BAD:
main() {}
void f() {}
GOOD:
main() {
f();
}
void f() {}
Usage
To enable the unreachable_from_main
rule,
add unreachable_from_main
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- unreachable_from_main