'How to configure VSCode to propose relative imports on packages in a monorepo?

We have a monorepo Flutter app with different features separated into packages. We use relative imports in every package, but the problem is that VSCode only proposes us to use packages imports when we are working on packages, having the IDE raised from the root of the main application. If we open VSCode only for the package, it proposes relatives imports. But this is not practical for us. Does anyone know how to configure VSCode to propose relative imports when we are editing code on a package inside the main app? Thanks!

PD: We use prefer_relative_imports: true lint rule already.



Solution 1:[1]

I found a plugin that will most likely answer your question. The plugin is called "dart-import" for VSCode and it allows you to change all imports to relative format.

2

And by default there is an option to choose the import method, hover over and select "Quick Fix..." or press Ctrl + . to bring up the import selection menu.

3

If my answer helped you, then please do not forget to mark my answer as correct (tick).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Legend5366