flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

Feature Request: Easier ways to Optimize imports

Open brianegan opened this issue 6 years ago • 9 comments

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.

screen shot 2018-03-01 at 3 07 56 pm

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:

screen shot 2018-03-01 at 12 13 53 pm screen shot 2018-03-01 at 12 13 57 pm

brianegan avatar Mar 01 '18 14:03 brianegan

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.

pq avatar Mar 01 '18 18:03 pq

I think this feature (or similar) exists now in Flutter plugin - format and organize imports on save. image

scheglov avatar May 04 '18 19:05 scheglov

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

brianegan avatar May 28 '18 23:05 brianegan

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.

pq avatar May 31 '18 13:05 pq

Excellent, thanks for looking into it and fixing that up!

brianegan avatar May 31 '18 13:05 brianegan

we need smarter imports

JarvanMo avatar Jul 28 '18 14:07 JarvanMo

Idea 1 would be my preferred choice using Android Studio/Intellij.

cirediew avatar Mar 12 '19 15:03 cirediew

any news update?

droplet-js avatar Oct 18 '21 03:10 droplet-js

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.

TheFabbiusCorp avatar May 10 '22 16:05 TheFabbiusCorp