flutter - viewing .pub-cache files gives Request textDocument/documentSymbol failed

Viewed 5384

I get these error messages every time I view the code of third party flutter packages (in .pub-cache folder):

[Error - 7:19:24 PM] Request textDocument/documentSymbol failed.
  Message: Invalid file path
  Code: -32003 
/Users/benjaminfarquhar/development/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.4+1/lib/src/hive_impl.dart
[Error - 7:19:24 PM] Request textDocument/codeAction failed.
  Message: Invalid file path
  Code: -32003 
/Users/benjaminfarquhar/development/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.4+1/lib/src/hive_impl.dart
[Error - 7:19:24 PM] Request textDocument/hover failed.
  Message: Invalid file path
  Code: -32003 
/Users/benjaminfarquhar/development/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.4+1/lib/src/hive_impl.dart
[Error - 7:19:25 PM] Request textDocument/hover failed.
  Message: Invalid file path
  Code: -32003 
/Users/benjaminfarquhar/development/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.4+1/lib/src/hive_impl.dart
[Error - 7:19:33 PM] Request textDocument/hover failed.
  Message: Invalid file path
  Code: -32003 
/Users/benjaminfarquhar/development/flutter/.pub-cache/hosted/pub.dartlang.org/hive-1.4.4+1/lib/src/hive_impl.dart

I didn't use to get them. Any ideas on how to fix?

I have tried changing the settings.json dart sdk setting from null to my dart sdk location: "dart.sdkPath": "/usr/local/opt/dart/libexec", but it didn't work.

3 Answers

I faced the same issue in vscode v-1.58.2,I googled it, some said to uninstall/install the flutter sdk, but after tracing a lot, the origin of the error , which was keeps on generating, whenever i hover, or clicked any part of the code.

Origin of Error

After including a code in the AndroidManifest.xml

<meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/transparent.png" />

which later on i commented and removed.

Solution

I just simply performed these steps...

enter image description here

and the problem got solved.

I Hope this could help someone.

For me, I got this error in main.dart (not in .pub-cache) on a project I'd been working on a while, when I was doing some cleanup and hovered on a warning:

warning example

I clicked on the "quick fix" for the "Use key in widget constructors" warning, which added the const... line below:

class MyApp extends StatelessWidget {
    
  const MyApp({Key? key}) : super(key: key);

After this, hovering over elements of the code kept generating the same error message you got. Deleting the new const... line gets rid of the problem.

I had tried the other solution about "close editor" "close folder" "close window" but didn't have any luck, nor had I modified my AndroidManifest.xml and it didn't contain that bit of code in it.

Related