Flutter autocomplete not working in VSCode for packages

3,615

Solution 1

You must make sure that your dependencies for plugins are mentioned under dependencies: section, not under dev_dependencies: section like following:

dependencies:
  flutter:
    sdk: flutter
  cloud_firestore: ^0.13.7
  firebase_auth: ^0.16.1
  fluttertoast: ^7.0.2

Solution 2

I was getting the same issue and fixed it by changing the flutter channel. The problem seems to be with the dart that ships with the flutter code.

If you are still facing this issue. Then try to change your channel

flutter channel ...

And then try

flutter upgrade

This will pull the dart version again and hopefully fix the import issue.

Share:
3,615
Alexandru Stroescu
Author by

Alexandru Stroescu

Updated on December 17, 2022

Comments

  • Alexandru Stroescu
    Alexandru Stroescu over 1 year

    I moved my whole flutter project to a new folder, everything runs fine. The autocomplete works on the build in files from flutter, like Container, Column, but when I try using a package, like provider, I need to go on the pub.dev page and copy the import, import it manually, then I have to write "Provider.of(context)" manually. In the old project, I used to write Provider, press TAB, and everything would be auto imported and the VSCode would auto complete everything related to provider, not just bult in files. Whan should I do?

  • Syed Usama Ahmad
    Syed Usama Ahmad over 3 years
    I also had the same issue so I synced the dependencies again and put them under (dependencies:) it worked fine
  • Muhammad Faizan
    Muhammad Faizan over 3 years
    Sometimes making this silly mistake is easy, may be due to time constraints or whatever but it is quite common and surprising thing is, plugin still works, just auto complete stops working.