dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.04k stars 1.55k forks source link

Import `new_library` assist should auto-remove unecessary import #55946

Open FMorschel opened 2 months ago

FMorschel commented 2 months ago

When working on Flutter projects, sometimes I extract a Widget to a new file.

While importing the missing dependencies with the assist, sometimes I miss click and import widgets first and then material. Which then warns me about the unnecessary import of widgets.

I believe that the assist should replace the old import if that happens.

bwilkerson commented 2 months ago

While importing the missing dependencies with the assist ...

Are you manually extracting the widget, or is the 'Move to File' refactoring sometimes not adding the imports automatically?

I believe that the assist should replace the old import if that happens.

That's definitely an interesting idea. I suspect the right way to do that would be to look to see whether the import being added exports an existing import.

FMorschel commented 2 months ago

Manually moving. This was before I found out about the new "Move to File" refactor.