Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter autocomplete not working in VSCode for packages

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?

like image 575
Alexandru Stroescu Avatar asked Mar 03 '23 20:03

Alexandru Stroescu


2 Answers

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
like image 74
Muhammad Faizan Avatar answered Mar 05 '23 08:03

Muhammad Faizan


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.

like image 36
Nitesh Avatar answered Mar 05 '23 08:03

Nitesh