I wasted my all day and i didnt understand what is going on. I'm using Visual Studio Code 1.40.2 and i am learning Flutter 3.60. Sometimes Flutter codes turn unreadable because of indent space. I only wanted to create more space (indent space) but when i use format option, tab size is turning again 2. I looked too many web sites including Stackoverflow and unfortunately i didnt find solution.It turned annoying. This is my config file: (Thanks for help)
{
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"editor.fontSize": 18,
"editor.fontFamily": "Consolas, 'Courier New', monospace, ",
"dart.openDevTools": "flutter",
"workbench.colorTheme": "Night Owl (No Italics)",
"workbench.iconTheme": "material-icon-theme",
"editor.fastScrollSensitivity": 8,
"editor.tabSize": 8,
"editor.insertSpaces": true,
"editor.wordWrap": "on",
"editor.smoothScrolling": true,
"editor.cursorBlinking": "expand",
"editor.cursorSmoothCaretAnimation": true,
"editor.fontWeight": "400",
"outline.showFields": false,
"[dart]": {
"editor.tabSize": 6,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
},
}
I added this block but didnt worked.
"[flutter]": { "editor.tabSize": 6, "editor.insertSpaces": true, "editor.detectIndentation": false, },
This is my simple code:
import 'package:flutter/material.dart';
class GridListe extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GridView.count(
crossAxisCount: 3,
primary: false,
padding: EdgeInsets.all(10),
crossAxisSpacing: 20,
mainAxisSpacing: 40,
children: <Widget>[
Container(
alignment: Alignment.center,
color: Colors.teal,
child: Text(
"Salam",
textAlign: TextAlign.center,
),
),
],
);
}
}
When i use format code (Shift + alt + p) Codes indent space or tab size turn 2 and it will make me crazy.
import 'package:flutter/material.dart';
class GridListe extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GridView.count(
crossAxisCount: 3,
primary: false,
padding: EdgeInsets.all(10),
crossAxisSpacing: 20,
mainAxisSpacing: 40,
children: <Widget>[
Container(
alignment: Alignment.center,
color: Colors.teal,
child: Text(
"Salam",
textAlign: TextAlign.center,
),
),
],
);
}
}
What is the best way to ensure consistent formatting in the Flutter code? DartFMT command replaces the whitespaces with the Dart-guidelines formatting.
Select the text you want to automatically indent.Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.
Add your this in your settings.json file
"[dart]": {
"editor.defaultFormatter": "Dart-Code.dart-code",
"editor.formatOnSave": true
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With