New lint: avoid_compile_constants #58165
Labels
analyzer-linter
Issues with the analyzer's support for the linter package
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
linter-lint-request
type-enhancement
A request for a change that isn't a bug
Avoid using compile time constants
The lint would trigger upon the use of the three Flutter fromEnvironment constructors:
int.fromEnvironment
string.fromEnvironment
bool.fromEnvironment
bool.hasEnvironment
should also trigger the lint.Using a compile constant creates a hidden global state in the program, with no defined method to determine the state or understand its use when reading the code (unlike flags a compile time constant might only be referenced during the fromEnvironment constructor call). If used heavily it makes the program hard to understand.
The text was updated successfully, but these errors were encountered: