You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong imports in Stateless Widget snippet from analysis server #49081
@bwilkerson do I recall you saying this may have already been solved somewhere outside of the server? The import is being added automatically by the edit builder (via writeType or similar). I'm not sure how it would know which exported library to add though (Flutter has many overlapping).
We could perhaps list the preferred imports with the snippet and add them (although we'd probably also need to either suppress the edit builder adding its own, or ensure it can tell that the written types are covered by an existing import that isn't where the type is declared).
The problem is that the analysis server doesn't currently have any support for keeping track of which public libraries export symbols declared in internal libraries. The dartdoc package has support for this, but the code isn't currently in a form that can efficiently be shared, nor does it deal with changes to the code (rightly so because it's a command-line tool rather than a long lived server).
Although we could special case this support for snippets, we need this information in lots of other places so I'd really prefer to just solve the problem once (most likely via DartEditBuilder) and share the solution across all of the features that need it.
It's possible that we could compute the information efficiently enough that we wouldn't need to cache anything (we should only need to look at the public libraries in a package, and there often aren't very many of those). That would be idea. Otherwise we'll need a cache and a reliable way of determining when the cache needs to be flushed.
@DanTup This is a still a major issue. as it slows developing time. I'm really looking forward to this update.
Reacted by Francisco Pitriqueo, Fareez Iqmal, kurbatxx, Radit Ananta, Hwanseok Kang (Barth), evaqum, Bin Liu, Richard James Beanland, Victor Eronmosele, monad154 and 1 more
I'm new to Flutter, but I found this issue annoying as this pops up every time when creating widget in new file. One workaround I'm using right now is adding import manually with some 3rd party snippet extension (details) first before running stlss.
This is still doing this in vscode, is there a way to manually go change the snippet file to change the imports to material, very annoying when its the first snippet to show up in the context menu all the time
There's no file you can modify as the imports don't come from a file but are inserted automatically by the Dart analysis server when references to types are added by the snippet.
This issue has been fixed, but the fix has not yet shipped in a stable release of Flutter. It is available on the Flutter beta channel and will be included in the next stable release.
Activity
DanTup commentedon May 23, 2022
@bwilkerson do I recall you saying this may have already been solved somewhere outside of the server? The import is being added automatically by the edit builder (via
writeTypeor similar). I'm not sure how it would know which exported library to add though (Flutter has many overlapping).We could perhaps list the preferred imports with the snippet and add them (although we'd probably also need to either suppress the edit builder adding its own, or ensure it can tell that the written types are covered by an existing import that isn't where the type is declared).
bwilkerson commentedon May 24, 2022
The problem is that the analysis server doesn't currently have any support for keeping track of which public libraries export symbols declared in internal libraries. The
dartdocpackage has support for this, but the code isn't currently in a form that can efficiently be shared, nor does it deal with changes to the code (rightly so because it's a command-line tool rather than a long lived server).Although we could special case this support for snippets, we need this information in lots of other places so I'd really prefer to just solve the problem once (most likely via
DartEditBuilder) and share the solution across all of the features that need it.It's possible that we could compute the information efficiently enough that we wouldn't need to cache anything (we should only need to look at the public libraries in a package, and there often aren't very many of those). That would be idea. Otherwise we'll need a cache and a reliable way of determining when the cache needs to be flushed.
fahami commentedon Oct 21, 2022
any progress for this issue?
bwilkerson commentedon Oct 21, 2022
Not that I'm aware of.
Samleet commentedon Nov 2, 2022
@DanTup This is a still a major issue. as it slows developing time. I'm really looking forward to this update.
Blayneliu commentedon Nov 27, 2022
I'm new to Flutter, but I found this issue annoying as this pops up every time when creating widget in new file. One workaround I'm using right now is adding import manually with some 3rd party snippet extension (details) first before running
stlss.htetlynnhtun commentedon Dec 5, 2022
We need a solution to this issue.
Technorocker commentedon Apr 20, 2023
This is still doing this in vscode, is there a way to manually go change the snippet file to change the imports to material, very annoying when its the first snippet to show up in the context menu all the time
DanTup commentedon Apr 20, 2023
There's no file you can modify as the imports don't come from a file but are inserted automatically by the Dart analysis server when references to types are added by the snippet.
This issue has been fixed, but the fix has not yet shipped in a stable release of Flutter. It is available on the Flutter
betachannel and will be included in the next stable release.