Everything worked fine until a couple of days ago. Whenever I create new widgets or create some files and want to use them, I don't manually type import package:...
but start typing the name of that class and press ctrl + .
which provided a list of Quick fix
es and always suggested import package:...
until recently. No changes to Windows / Flutter / Dart / VS Code have been made except I installed svg-explorer-extension after following this advice (which I would highly doubt affected anything, yet it still updated some x64 c++ distribution something).
Right now, as I try to use existing files (all of them are in */lib folder) in the new files I create, the Quick fix
menu provides all except import package:...
options which makes the development process slow enough to ask a question here.
The only way to 'recover' that functionality is to run Developer: Reload Window
in VS Code which stops the debug session, restarts Dart Analyzer
, and everything seems to be okay for the next couple of minutes until it simply disappears.
How to not 'lose' that importing functionality? My project is rather big (22k lines) with 30+ dependencies. I tried reinstalling flutter SDK, flutter, and dart extensions from VS Code and that didn't help.
What suggestions do you have? Is this issue worth filing an issue for Flutter / Dart / Flutter Extension on GitHub?
I was also stucked in this issue and the real answer to this question according to my analysis is : always create new widgets or dart classes within lib folder. You can create different folders such as widgets, screens, models but always create them in lib folder dont create them at the root level. Your problem of import will be solved. Infact VSCode will auto-import them
You can refer to this image below and see how I organized my lib folder [1]: https://i.stack.imgur.com/Yau5i.png