My line length for Dart code


My line length for Dart code

I know that the recommended wrapping line length is 80 characters for source code and it has been that way for many years. Historically, it has been that way due to old computer terminals and possible optimal reading. However, these days, with wide monitors and larger coding surfaces, I find this recommendation outdated.

For many years now I have written all of my Dart code using a maximum line length of 110 characters. This will wrap my code automatically after reaching that limit. In VS Code you change this setting in the Extensions > Dart > Editor > Dart: Line Length field. Just replace the 80 with 110 which I find to be optimal.

I know the recommended length is 80 characters, but I find that 80 is too short which causes too much unnecessary wrapping of source code. I use 110 for all of my code except for packages that I published to pub.dev as open source. That is because that code would be flagged by the linter during static analysis, and the score would be reduced.

Try it for yourself and see that it makes your code more readable.

Larry Aasen
Written by Larry Aasen Lead mobile engineer at Car IQ. Author of the apps Auto Care Kit and US Debt Now, and the Flutter package upgrader.