'Why is my Dart code auto-moved to a different line, when I Ctrl+S?

What happened is that when I move my codes to different lines, and when I CTRL+S, the code automatically get moved to a different line.

enter image description here

What setting in VS Code is this?



Solution 1:[1]

That's because you have format on save.

You need to go to VS Code settings and search formatOnSave and turn it off

Solution 2:[2]

check if the "auto format on save" option is on: VSCode: How do you autoformat on save?

you can also go into the dart plugin's preferences in vscode and change the line length at which formatting the code will auto-wrap it. You can make it however long you want. Just go into settings and search "Dart: Line Length"

Solution 3:[3]

For me, I went to the dart extension setting, there is an option of Dart: Enable SDK Formatter. It should be the problem I guess because when I disabled it, everything started working fine.

We can directly search for Dart: Enable SDK Formatter in VS Code settings.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sebastian
Solution 2 Kris
Solution 3 Ayush Mishra