proper_from_environment

SeverityQuick FixOptions
Error

Details

DO use const when invoking bool.fromEnvironment, int.fromEnvironment and String.fromEnvironment.

The constructors bool.fromEnvironment, int.fromEnvironment and String.fromEnvironment are only guaranteed to work when invoked as a const constructor.

see: dart-lang-issue

Bad
final boolean = bool.fromEnvironment('bool');
int integer = int.fromEnvironment('int');
var string = String.fromEnvironment('String');
Good
const boolean = bool.fromEnvironment('bool');
const integer = int.fromEnvironment('int');
const string = String.fromEnvironment('String');

Usage

To enable the proper_from_environment rule, add proper_from_environment under plugins > pyramid_lint > diagnostics in your analysis_options.yaml file:

plugins:
  pyramid_lint: <version>
    diagnostics:
      proper_from_environment: true