lines_ longer_ than_ 80_ chars
Learn about the lines_longer_than_80_chars linter rule.
Avoid lines longer than 80 characters.
Details
#AVOID lines longer than 80 characters
Readability studies show that long lines of text are harder to read because your eye has to travel farther when moving to the beginning of the next line. This is why newspapers and magazines use multiple columns of text.
If you really find yourself wanting lines longer than 80
characters, our experience is that your code is likely too
verbose and could be a little more compact. The main offender
is usually VeryLongCamelCaseClassNames. Ask
yourself, “Does each word in that type name tell me something
critical or prevent a name collision?” If not, consider
omitting it.
Note that dart format does 99% of this for you,
but the last 1% is you. It does not split long string literals
to fit in 80 columns, so you have to do that manually.
We make an exception for URIs and file paths. When those occur in comments or strings (usually in imports and exports), they may remain on a single line even if they go over the line limit. This makes it easier to search source files for a given path.
Enable
#
To enable the lines_longer_than_80_chars rule,
add lines_longer_than_80_chars
under
linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- lines_longer_than_80_chars
If you're instead using the YAML map syntax to configure
linter rules, add
lines_longer_than_80_chars: true under
linter > rules:
linter:
rules:
lines_longer_than_80_chars: true
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.