Mahesh Gouda
Mahesh Gouda

Reputation: 148

Android studio shows can not find Declaration to go to in flutter project

while working on a flutter project, Android studio behaving strangely for some of the dart files is shows Cannot find declaration to go to even for BuildContext. ( Project runs without any errors )

issue snapshot:

enter image description here

while some of the dart files in the same project are able to go to the declarations and find the references.

I have already tried the following methods:

None of the above methods worked for me, Is there any way to resolve this error? any suggestions or solutions would be very helpful.

Upvotes: 5

Views: 4441

Answers (4)

Gagan Yadav
Gagan Yadav

Reputation: 141

Going over to File > Invalidate Caches.. solved the problem for me. Or maybe it was just the restart of the IDE.

Upvotes: 0

Mobileur
Mobileur

Reputation: 11

I had deleted some of the things from External Libraries in Android Studio and I was getting the same error.

Tried to Invalidate Caches, Repair IDE, and do much more.

How I fixed it: I just downloaded Flutter SDK and replaced the one I had in my PC.

Hopefully, it'll work for you guys too. Thank you.

Screenshot of Android Studio

Upvotes: 1

Andy King
Andy King

Reputation: 1662

I hit the same error ... the code compiled cleanly, and ran, but I was not able to go to the declaration for any properties or classes, etc. I noticed that the code folding indicators weren't showing after a certain point in the file, so I think Visual Studio is getting confused. In my case, I moved a static method from the start of the class to the end, and this resolved all of the problems except for references within that static method. I'm using Android Studio Flamingo/2022.2.1 Patch 2 (built on May 12, 2023).

Upvotes: 1

Mahesh Gouda
Mahesh Gouda

Reputation: 148

I was able to resolve this issue just by deleting the @override and writing it again..

enter image description here

Upvotes: 3

Related Questions