Flutter解决Cannot resolve symbol ' xxx'

505 阅读1分钟

在Flutter项目中,打开Android项目后,发现Androidstudio提示Cannot resolve symbol 'xxx',明明这些代码已经是在项目中了,居然无法识别在同一个包里面的其他类。项目依赖和编译都没有问题,就是代码会报红,这对于写代码就非常不方便了。

解决方案: Androidstudio > File > Invalidate Caches... > Invalidate and Restart

image.png

Androidstudio > File > Sync Project With Gradle Files

image.png