문제 설명
경고 대신 오류로 "@required" 주석 ("@required" annotation as error instead of warning)
지금 Flutter 프로젝트에서 @required
로 생성자 매개변수에 주석을 달고 생성자를 인스턴스화할 때 잊어버리면 IDE에서 매개변수가 필요하다는 가벼운 경고를 받습니다.
이것이 IDE에서 실제 오류로 표시되기를 바랍니다. analysis_options.yaml
또는 다른 곳에 경고 대신 오류로 설정하는 방법이 있습니까?
참조 솔루션
방법 1:
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
(by Graham、Günter Zöchbauer)