Closed apaatsio closed 5 years ago
Somewhat related discussion: flutter/flutter#31448
dartfmt is opinionated by design. It does it's best to format your code to one canonical style so that all code formatted using dartfmt is consistent.
The linter is not opinionated. Most lint rules do fit within dartfmt and "Effective Dart"'s guidelines, but some do not. If you choose to enable a lint rule that conflicts with dartfmt, then using dartfmt will produce lint errors.
The easiest fix in this case is to always put braces on your ifs. The lint is happy with braced ifs and dartfmt will format them the way you expect. It is only on unbraced ifs where you run into conflict.
dartfmt
formats code in a way that doesn't agree with the linter rulealways_put_control_body_on_new_line
. This creates quite an annoying problem where I cannot usedartfmt
if I want to use the rulealways_put_control_body_on_new_line
, and I cannot use the said linter rule if I want to usedartfmt
.Here's an example. Linter finds no issues before formatting but finds one issue afterward.
Log
Versions