This is a VS Code extension that sorts your dart / flutter imports with a single command.
There are three ways to activate the extension:
By default, this extension will group your dart imports according to source and
Sort On Save
You can set the extension to sort your dart imports whenever you save your
current active document. This is set to
Custom Sorting Rules
You can set your own sorting rules so that imports will be grouped and ordered according to your preference.
How it works
The sorting algorithm only looks at a certain part of the import statement, namely the parts between the quotes. Keep this in mind when writing your own rules.
For example, the following:
is simplified to
See the following example:
Default Sorting Rules
The extension comes with the following default rules:
You project name is detected automatically from pubspec.yaml and replaces
If you don't provide custom rules in settings.json, then the extension will use these rules by default. If you provide any configuration whatsoever, then the extension will use only your configuration, completely disregarding the defaults.
Contact me at firstname.lastname@example.org. I'd love to collaborate!
Configuration inspired by this extension (typescript import sorter)