Flutter file: "Cannot find declaration to go to" for local, existing method

Answered

Hi,

I've got a Flutter project. Sometimes, the Dart parser fails to find methods of a class when I use the "Go to - Declaration or Usage" on a method reference. Does anybody know how to fix this?

In the example below, it happened after I added the method "_buildBooking()": I can go to the declaration of this newly added method - but not to the ones that were there before. But when I copy the name of a "Cannot find declaration to go to" method (like "_buildRoute()"), then IntelliJ finds it just fine via "File - Navigate Structure". 

Here's a screen recording of this error. Please note that my keyboard commands are printed at the bottom; the video bar may hide that. If you leave your mouse cursor alone, that bar disappears after a few seconds.

This is my environment:

  • macOS Big Sur 11.4
  • IntelliJ IDEA 2021.1.1 (Ultimate Edition), Build #IU-211.7142.45, built on April 30, 2021
  • Runtime version: 11.0.10+9-b1341.41 x86_64
  • Dart: 211.7233
  • Flutter: 56.0.5


Regards,
Karsten Silz

0
4 comments

This problem persisted after an IntelliJ restart.

0

May you clear caches using "File | Invalidate caches and restart"? Does it help? 

0

Clearing the caches did not help. I tried once with "Clear downloaded shared indexes" unchecked and then once with it checked. The problem persisted in both cases.

0

Please sign in to leave a comment.