question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

extension 'flutter' cannot format '.dart'

See original GitHub issue

屏幕快照 2020-03-15 13 14 09

Environment

  • vscode: 1.43.0
  • flutter extension: 3.8.1
  • dart extension: 3.8.1
  • settings.json
{
  "editor.fontSize": 13.5,
  "editor.fontFamily": "Fira Code",
  "editor.fontLigatures": true,
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "Dart-Code.flutter"
}

Expectation

屏幕快照 2020-03-15 13 17 39

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

25reactions
DanTupcommented, Mar 15, 2020

"editor.defaultFormatter": "Dart-Code.flutter"

The formatter for Dart is in the Dart extension (since it should work for non-Flutter users too), so if you’re setting the formatter explicitly for Dart you should set it to Dart-Code.dart-code.

That said, this formatter can *only format Dart, so you shouldn’t set it as the default formatter for all lanuguages, as it will prevent you from being able to format other languages.

Unless you have good reason, you should be able to just delete that line from your settings - VS Code will use the Dart formatter for Dart files automatically without any specific configuration.

Let me know if this doesn’t seem to work for you. Thanks!

4reactions
vaibhavcs99commented, Dec 16, 2020

"editor.defaultFormatter": "Dart-Code.flutter"

The formatter for Dart is in the Dart extension (since it should work for non-Flutter users too), so if you’re setting the formatter explicitly for Dart you should set it to Dart-Code.dart-code.

That said, this formatter can *only format Dart, so you shouldn’t set it as the default formatter for all lanuguages, as it will prevent you from being able to format other languages.

Unless you have good reason, you should be able to just delete that line from your settings - VS Code will use the Dart formatter for Dart files automatically without any specific configuration.

Let me know if this doesn’t seem to work for you. Thanks!

Thank You, this is working for me now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio Code Flutter Format is Not Working with My ...
The Dart extension for VS Code uses the formatter from the Dart SDK (dart_style) which does not support customising the indent options (by ......
Read more >
Debugging why flutter format did not work on visual studio code
I started getting error as “Extension 'Flutter' cannot format 'lib/body.dart'” here 'lib/body.dart' is file that I was trying to format.
Read more >
Code formatting - Flutter documentation
Automatically formatting code in Android Studio and IntelliJ. Install the Dart plugin (see Editor setup) to get automatic formatting of code in Android...
Read more >
Visual Studio Code - Dart
With the Dart plugin, you can use Visual Studio Code (VS Code) to develop Dart apps. The Flutter site has details on how...
Read more >
VSCode Shortcuts, Extensions & Settings for Flutter ...
VSCode Extensions for Flutter Development · 1. Dart Data Class Generator · 2. Flutter Riverpod Snippets · 3. Error Lens · 4. Better...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found