-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import new_library
assist should auto-remove unecessary import
#55946
Comments
Are you manually extracting the widget, or is the 'Move to File' refactoring sometimes not adding the imports automatically?
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. |
Manually moving. This was before I found out about the new "Move to File" refactor. |
I was thinking a bit more about this request. Some things I was considering: If there is a need to add a new import which would not be aliased or have a combinator, it might give out some If there is only one existing library import that this new library exports (if are adding
I'm not sure what else to consider or if you agree with this but this is what I think would make this more consistent. ** One thing that I was worrying about when suggesting moving the alias to the new library would be making the new import have an alias that would not reflect what it is like if we had an Or we simply won't affect either an aliased import or one with combinators. That would give the user more to deal with (the same as today, basically). |
I'm a bit confused. I think I've lost track of what we're talking about here. Can you provide a small example of what you'd like to see the fix do? |
The base request is that code like this where import 'package:flutter/widgets.dart';
Widget f() {
return Scaffold(
body: Column(),
);
} This case is simple and the widgets import should be replaced by material. My last comment is talking about cases like the following where you have import 'package:flutter/widgets.dart' show Column, Widget;
Widget f() {
return Scaffold(
body: Column(),
);
} In this case, I believe we should still keep all My question on the above comment is whether or not we should handle cases like prefixed imports (today we now already have an "Import library with prefix" fix so this could mean the same prefix for both imports and it would trigger |
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 thenmaterial
. Which then warns me about the unnecessary import ofwidgets
.I believe that the assist should replace the old import if that happens.
The text was updated successfully, but these errors were encountered: