The dart team has started to work on a code formatter inside the Analyzer package but it's still a work in progress. You can have a look at the CodeFormatter class. You can also follow the corresponding issue : Dart formatter.
Is there any command line tool to format dart code?
-
02-06-2022 - |
Question
I want to use sublime to write dart code. It has a dart plugin which can highlight the syntax, but can't format it.
I searched and found there is no plugin for sublime for now to format the dart code, so I want to find a command line tool, and invoke it from my sublime.
Is there such a tool?
Solution
OTHER TIPS
This answer is not about a command line tool, but if you have WebStorm, there is a Dart plugin for it under Settings->Plugins.
After you have installed it, you can just open any file and press ctrl+shift+f to format it.
for the command line: dartfmt: The Dart Code Formatter
In DartEditor this can now be done using the context menu inside the code window and choose 'Format' or just press Ctrl+Shift+r
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow