Flutter-intellij: FR: dartfmt on save support

Created on 12 Jul 2017  路  3Comments  路  Source: flutter/flutter-intellij

I've been using Atom for Flutter development (even without the Flutter plugin) for several months.

My biggest reason for staying is that Atom will run dartfmt when I save. I haven't had to think about formatting my code since I started using it, and that's a fantastic savings in engineering productivity.

Can we add support to run dartfmt on save to IntelliJ?

dart plugin enhancement

Most helpful comment

You could also do this with a Macro:

Edit > Macros > Start Macro Recording
Code > Reformat with Dart Style
File > Save All
Edit > Macros > Stop Macro Recording
Name the macro, and hit OK

Next, open Preferences, locate Keymap, search for the macro by the name you gave it, right-click, and assign cmd-s to it.

All 3 comments

True IntelliJ users rarely perform Save action, but they do frequently use Reformat Code action (Ctrl+Alt+L or Cmd+Alt+L). So in IntelliJ we tied a call to the dartfmt tool to the IDE's standard and well-known formatting action. This is a new feature of version 2017.2, the option that enables dartfmt tool is in Settings (Preferences) | Editor | Code Style | Dart page

You could also do this with a Macro:

Edit > Macros > Start Macro Recording
Code > Reformat with Dart Style
File > Save All
Edit > Macros > Stop Macro Recording
Name the macro, and hit OK

Next, open Preferences, locate Keymap, search for the macro by the name you gave it, right-click, and assign cmd-s to it.

Thanks @mit-mit!

Was this page helpful?
0 / 5 - 0 ratings