Adding new package in a flutter project does not work untill the android studio is restarted

36 Views Asked by At

I am facing this problem for a while now. When i add a library or package in a flutter project and then run flutter pub get But when i import that package, it is not available (as if it is not included in pubspec) As long as i Know, running the command flutter pub get

actually downloads that package but for some reason is not availale to be used in the project files. I have to restart the android studio every time to use the new library

I tried the following but they did not help.

  1. Open andriod studio in administrator mode
  2. Delete the pubspec.lock file
  3. Upgraded the flutter to latest version
  4. Upgraded the android studio to latest version
  5. Open pubspec.yaml and then press Get Dependencies
  6. Add the package using Terminal for example flutter pub add library_name

All these do not help and I must have to restart the android studio. Then everything works.

Additional Info I wonder if it has to do something with my project structure or something. Because i craeted a new flutter project and there is no such problem.

0

There are 0 best solutions below