5

I find it incredibly distracting to code with 2 spaces indentation, so I always set my indentation size to 4 spaces, however, on this flutter project, the indentation stays at 2 spaces, no matter what I change, it refuses to be 4 spaces... (this applies to all files, not just the main.dart file)

Example of spaces in my code

I've tried setting indentation spaces to 4 from 2 (https://stackoverflow.com/a/37077167/15586166 and https://stackoverflow.com/a/51398290/15586166) but even when it is set to 4 spaces for Dart specific projects (the json file), workspace settings (assuming frontend for json file) and in the VSCode user settings tab, it goes back to 2 spaces on format (or rather the settings stays at 4 spaces, but it still formats at 2 spaces). I do not have a .editorconfig, so I couldn't change it there. I've also disabled detect indentations (https://stackoverflow.com/a/43809036/15586166) on all the levels I did with the indentations sizes.

JSON settings

User settings

VSCode spaces display preview

Could it be that dart_style (which I am assuming is formatting the code), enforces 2 spaces indentations? If it is, is it possible to change it?

dart style enabled

Although, taking a look through its code, it shouldn't be enforcing 2 spaces, like this function. (see image)

Code Snippet

I also only have these 2 extensions for Dart/Flutter, and only Prettier formatter (only other formatter), but disabling it does not fix the issue...

Extensions

Netsu
  • 1,399
  • 1
  • 7
  • 18
  • Tbh with how flutter is structured it's better to use 2 spaces. – LacticWhale Nov 17 '22 at 18:28
  • @LacticWhale Yeah, I guess, if I can't change it, then I'll make do, it's not the end of the world, just an annoyance – Netsu Nov 18 '22 at 04:37
  • 1
    it also annoyed hell out of me XD. But later I noticed how "hilly" flutter code is. – LacticWhale Nov 18 '22 at 06:12
  • 2
    I fail to see "with how flutter is structured it's better to use 2 spaces". How does indenting with 4 spaces make one iota of difference to the language? I just started looking at Flutter but forcing me to not see the code indentation clearly enough is going to make life a living hell. – Marc Fearby Apr 02 '23 at 02:00

0 Answers0