Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"@required" annotation as error instead of warning

Tags:

flutter

dart

Right now in my Flutter project when I annotate a constructor parameter with @required and forget it when instantiating the constructor, I get a light warning from my IDE that the parameter is required.

I would like this to show up as an actual error from the IDE. Is there a way in analysis_options.yaml or somewhere else to set it as error instead of warning?

like image 245
Graham Avatar asked Jan 09 '19 19:01

Graham


1 Answers

In analysis_options.yaml add

analyzer:
  errors:
    missing_required_param: error

before

 $ flutter analyze
Analyzing flutter_0_generic...                                   

   info • The parameter 'onPressed' is required • lib/main.dart:49:33 • missing_required_param

1 issue found. (ran in 2.2s)

after

 $ flutter analyze
Analyzing flutter_0_generic...                                   

  error • The parameter 'onPressed' is required • lib/main.dart:49:33 • missing_required_param

1 issue found. (ran in 1.8s)

See also https://www.dartlang.org/guides/language/analysis-options#changing-the-severity-of-analysis-rules

like image 61
Günter Zöchbauer Avatar answered Sep 22 '22 08:09

Günter Zöchbauer