Skip to content

Old formatting notes

Brady Trainor edited this page Aug 1, 2021 · 1 revision

This is all more-or-less deprecated. This dart-mode project no longer provides the functions to interact with the dart analysis server. That was moved to dart-server.el, and is described at “Recent changes”.

Please see new formatting notes at “Formatting” wiki page.

Using dart-formatter

To format your dart file, you can call the command dart-formatter via the keybinding, C-c C-o. We recommend you use the following setting for convenience, so that your code is formatted on each save.

(setq dart-format-on-save t)

Troubleshooting

Ensure dartfmt is available

Formatting is done by calling out to the dartfmt executable. You will want to make sure that dart or flutter are on your system PATH.

If you’re not able to do that, you can also set the path in your init, with, dart-sdk-path or dart-formatter-command-override.

Ensure diff is available

Especially on Windows, you may have to add diff to your system and PATH.

One way to do this is install from http://gnuwin32.sourceforge.net/packages/diffutils.htm and add something like the following to your init file.

(setq exec-path (append exec-path '("C:/Program Files (x86)/GnuWin32/bin")))

On Windows, you may find this all easier via chocolatey, which is anyways apparently a recommended method to install dart on Windows.