How to increase the width of the code line in Android studio?
Asked Answered
A

5

33

I am using Android studio to develop a flutter app, when I click reformat code with dart format it breaks in unpleasing format. enter image description here

Even though there is lot of space it breaks the line, how can i increase the line width?

Adeline answered 16/11, 2019 at 11:58 Comment(2)
Check if its a plugin causing the issue or check this out if it might help #30852117Cates
Thanks for your comment, I changed Settings->Editor -> Code style -> Dart -> Wrapping and braces (tab) -> changed Hard wrap at to '150'Adeline
A
74

I solved this issue by changing Settings -> Editor -> Code Style -> Dart -> Line length to 150

Adeline answered 16/11, 2019 at 18:14 Comment(2)
To me it was..... Settings->Editor -> Code style -> Dart -> Line lengthWilmoth
For me this moves the vertical guide, but Dart auto formatting still breaks the line after 80 chars. Any solution?Persecution
B
10

FOR MAC OS:

Android Studio -> Preferences -> Editor -> Code Style -> Dart -> Line length: int

Banyan answered 10/11, 2020 at 16:13 Comment(0)
A
7

Go to settings -> Editor -> Code Style -> Dart, you can change line length to what ever value you want, but based on Effective dart style, it's better to avoid lines longer than 80 characters. see this docs https://dart.dev/guides/language/effective-dart/style

enter image description here

Agreed answered 11/1, 2021 at 1:53 Comment(0)
K
2

I'm not sure how to change the settings, maybe with an Android Studio plugin, but as described in the Dart docs you should avoid lines with more than 80 characters of code. Try to structure your code a bit then you have more overview instead of squeezing everything in one method, widget or whatever together

Link to Dart docs

Kokoruda answered 16/11, 2019 at 12:39 Comment(1)
IMHO, this rule has negative effect in common. Actually it is rudimental rule from the past. As Linus Torvalds said: People with restrictive hardware shouldn't make it more inconvenient for people who have better resources. Yes, we'll accommodate things to within reasonable limits. But no, 80-column terminals in 2020 isn't "reasonable" any more as far as I'm concerned. People commonly used 132-column terminals even back in the '80s, for chrissake, don't try to make 80 columns some immovable standard.Outwardbound
C
2

For VS Code:

File -> Preferences -> Settings -> Dart&Flutter: Dart: Line Length

Cordwood answered 9/3, 2021 at 19:31 Comment(1)
This does not answer the question which specifically concerns Android Studio. Nevertheless, your answer might be useful for VS Code users.Moyna

© 2022 - 2024 — McMap. All rights reserved.