The original address: www.370codes.com/flutter/202…
Original author: www.370codes.com/
Release date: June 13, 2021 – approximately 3 minutes
In this article, I will recommend some Settings for VS code that I use to improve my efficiency in developing applications using the Flutter framework.
Turn on Dart Settings in VS-Code
To turn on the Dart engine Settings in VS-Code, you only need one command.
- Open the command palette in VS code (Command /Ctrl + Shift + P
- Search for “Dart: Use recommended Settings “.
- Now, you’ll see a dialog box that says turn on Settings.
- Once you click on it, it opens the Dart Settings page, “Settings. json.”
Also, if the dialog box is not displayed. You can go directly to VS Code Settings.
And search “dart “for a reference to the settings.json file.
Understand the setup
Let’s take a look at each line in settings.json to see what they actually do.
"editor.formatOnSave": true."editor.formatOnType": true.Copy the code
These two lines are self-evident. The first line is to format the code when you save, and the other line is to try to format the code when you type (for example, when you type “; “Or comma, it will automatically format immediately).
"editor.rulers": [
80].Copy the code
This is one of my favorite Settings. This can sometimes make code much more readable. Let me explain.
This setting is responsible for the faint gray line you see when you open the DART file. You might ask, why does this line exist? It just helps improve the readability of the code. When the widget’s code goes beyond this line, it formats it to the next line.
In the image above you can see that the font weight property crosses the light line and is formatted to the next line when saving the file.
"editor.selectionHighlight": false."editor.suggest.snippetsPreventQuickSuggestions": false."editor.suggestSelection": "first"."editor.tabCompletion": "onlySnippets"."editor.wordBasedSuggestions": false
Copy the code
The others are self-evident.
“SelectionHighlight” controls whether the editor should highlight matches similar to the selection.
“SnippetsPreventQuickSuggestions” segments of control activities will stop quickly.
SuggestSelection “suggestSelection” controls how to preselect a suggestion when the suggestion list is displayed.
“TabCompletion” enables TAB completion, and “Word Suggestions” controls whether completion should be calculated based on words in the document.
The most effective of these suggestions is
I know you’re all waiting for the Easter egg, and it’s right here. The most helpful setting is to help you easily read the widget tree.
Yes, that dotted line helps us easily find wiget nested under another widget. No, this isn’t any fancy extension, it’s just an experimental setup for the Dart engine.
At the time of writing this blog, this feature is still in the preview phase.
"dart.previewFlutterUiGuides": true."dart.previewFlutterUiGuidesCustomTracking": true.Copy the code
Enable this setting and save the file. You may need to restart the VS code to start working and display your widget tree.
Hopefully this will help you increase your productivity, or help you improve the readability of your code.
Translation via www.DeepL.com/Translator (free version)