Add Arguments to dartfmt in VSCode - flutter

I am currently using vscode for flutter and dart development and wanted to increase line length from 80 to 120 characters (which can be achieved by dartfmt -l 120). However, there does not seem to be a way to directly set that in the VSCode Flutter and Dart Extension. Is it possible to do this?

The VS Code Dart extension (version 3.18.1 as of writing) provides a "Dart: Line Length" option (dart.lineLength).

Related

Dart is not running in vscode

I decided to start coding a language and I chose dart i previousy coded Html,css and javascript as my first language. I have no experience with flutter or vs code so when I downloaded the dart extension and sdk. I tried to run code it is recognized as dart because of its color but isnt running. Here is an open python document and Dart document.(https://i.stack.imgur.com/6X0kt.png)
(https://i.stack.imgur.com/v2QpT.png)
I restarted Vs code multiple times but It didnt work. This is really frustrating cause I havent started coding and I have already ran into a ditch
First you need to choise os, then follow the instructions:
https://docs.flutter.dev/get-started/install

Flutter and Dark extensions not showing in Visual Studio Code

I am trying to learn how to use Flutter and am using Visual Studio Code. When in Visual Studio Code and with a project selected, I try to: run > run without debugging. I am then supposed to see a list of my installed extensions to choose between - something like this:
but instead I see:
as if there are no extensions installed. However you can see:
that I do have Flutter and Dart extensions installed.
So I'm trying to figure out why my extensions are not showing. Any help gratefully received!
I am using Ubuntu 18.04.
You need to open main.dart or any other dart file. Then do run without debugging.

Unable to use extensions in flutter

Visual Studio Code gives errors when i try to use extensions in my flutter app
and i guess i have required version of dart installed
As per the first error i have enabled experiments in analysis_options.yaml (suggested in this link )
Please suggest if i am going wrong anywhere or missing the inclusion of any dependencies?
You have a correct version of Flutter/Dart, which should have extension methods enabled.
Are you sure that your VS Code is using that version?
Try opening "settings" in VS Code (File > Preferences > Settings) and enter (copy) the following into the search field:
#ext:dart-code.dart-code sdkPath
This should show a number of entries, Dart: Sdk path(s) and Dart: Flutter Sdk path(s). If any of these are set, it might be used instead of the Flutter SDK that you see on the command line.

VS Code and Flutter/Dart, Widget Autocomplete not working

I'm working with some tutorials to learn Flutter and the one that I'm taking now uses VSCode. I actually prefer it to Android Studio because it doesn't overheat my Macbook. The only frustration I've had with it so far is that there are quite a few times where autocomplete just stops working. For instance, if I wrap a Column in a widget and then start typing Container, Android Studio will pop up an autocomplete showing Container VS Code used to do this for me, but has stopped for some reason. I can still get the autocomplete list if I press Ctrl+Spacebar.
I'm using the following:
VS Code - 1.36.1
Dart Extension - 3.2.0
Flutter Extension - 3.2.0
Material Icon Theme - 3.8.0
This is the latest version for all of these.
Is there some setting or something that I need to change? I've spent the last two hours trying to work out what's going on. In searching, I did see some references to earlier versions of VS Code and the extensions causing problems, but nothing about these versions.
Go to pubspec.yaml and hit save or run get packages. It worked for me, hope it helps
There are generally two reasons for VS Code to automatically open code completion - 1) when you press a key that the extension ahs told VS Code should invoke it and 2) when VS Code thinks it would be useful (for example when you start typing on a blank line). If you're typing in a line of existing code it won't always do this.
Pressing Ctrl+Space is the correct way to open completion in the cases where it doesn't appear automatically.
That said, if you can provide more information about a specific instance, I can take a look if it's something we could/should pop completion open for. It would be best raised at https://github.com/Dart-Code/Dart-Code/issues with a screenshot and details of exactly where your cursor is (and how you got there).
dont use too many flutter extension, I also face this problem , then I realize that 3 flutter extension are installed, use only one , it works for me, try it.
I did have a derivative of this problem when I was working with VS Code and flutter and this is what I did.
This is for windows though. This is what I did ;
Go to C:\Users<your username >\AppData\Roaming\Code and delete all the files and the directory called "Code". Usually the folder AppData is hidden so you'll have to unhide it. Then restart your computer and then reopen VS Code. This I think cleared some of the unwanted cache files which kind of made things right again.
Hope it helped.
Make sure
Preferences > Editor > Intentions > Quick assist powered by the Dart
Analysis Server
is enabled (Screenshot).
If so, most likely your Dart Analysis server is crashing. Navigate to your HOME folder:
cd ~
And then below should resolve your issue:
sudo chown -R $USER .dart .flutter
Clear your cache if the issue still exists:
File > Invalidate Caches > Clear file system cache and Local History > Invalidate and Restart.
Also, Power Save Mode should be disabled:
File > Power Save Mode
Doing a flutter clean and then flutter pub upgrade worked for me. Sometimes flutter clean using the command line does not work if you have android studio then in tools go to flutter and then do flutter clean.
just do flutter clean then flutter create. and then flutter pub upgrade, and also see if your flutter SDK is latest or not.
Check to make sure Android Studio is not on low power mode
Menu>File>Low Power Save Mode
I solved in in my Macbook Pro by
Going to System Preferences > Keyboard > Shortcuts > Input Sources
Disable: Select the previous input source (^ space)
Updating VS Code dart and flutter extensions
Restarting the computer.
And voila! Ctrl + space now shows options in VS Code.

How to turn off formatter for a single file in VSCode?

I am using VSCode with editor.formatOnSave set to true. I want to turn off the formatter for a single file alone. Is there a way to do this?
I am using VSCode version 1.11.2 on Mac.