flutter-intellij
flutter-intellij copied to clipboard
Feature Request: Easier ways to Optimize imports
Hey all, @pq had an interesting PR against a project of mine: helping me sort imports.
I realized: Is there any way we could make this easier for end users? For example, Java has the "Optimize Imports on the fly" functionality. Is that possible for Dart?
Btw, the fact I'm asking about these nitty-gritty details shows how good the plugin is getting! Thanks again for all the hard work :)
Idea 1: Optimize Imports on the Fly
In IntelliJ, you can find the setting under Editor > General > Auto-import > "Optimize Imports on the Fly", but the option is only available for Java in my Editor.

Idea 2: Automatically run "Optimize Imports" on format
You can manually enable this option, but it might be neat if it was enabled for ya by default!
Screenshots of how to enable:


Thanks @brianegan ! As it happens we were just talking about this yesterday. 👍
I actually like both of your proposals...
cc @jwren and @alexander-doroshko for thoughts on implementing in the Dart Plugin.
I think this feature (or similar) exists now in Flutter plugin - format and organize imports on save.
Hey all -- just a heads up that I've been trying this feature and really like it overall. Thanks for adding it!
One bug I've seen: if I save too many times too quickly while hot reload is running, my editor will often hang (not crash) while showing a "Performing Hot Reload" spinner in the Status Bar. After it hangs, I must force close IntelliJ and boot it back up.
I'm a bit of a cmd+s spammer, so it might be my bad :P
I'm a bit of a cmd+s spammer, so it might be my bad :P
😄
~Not your bad at all. I'm assuming you have format-on-save enabled?~ (edit: duh, or we wouldn't be here) If so, should be fixed w/ #2293.
Excellent, thanks for looking into it and fixing that up!
we need smarter imports
Idea 1 would be my preferred choice using Android Studio/Intellij.
any news update?
Hello, I'm trying to use this existing feature, but it seems that it's not working at all with .dart files. I was wondering if it's just me or if anybody else has the same issue.