简体   繁体   中英

How to clear flutter deps and packages cache?

My vs code came up with a "get packages" button and I mistakenly pressed it.

这样的帮助

Now even though my packages are pinned (one in particular) at a certain version, it always tries to run the project with the latest version, which gives me errors like this:

/C:/Users/j/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/serverpod_serialization-0.9.20/lib/src/serialization.dart:21:11: Context: 'SerializableEntity.toJson' is defined here.

Notice it is referencing serverpod_serialization-0.9.20

I have all my serverpod stuff pinned at ^0.9.8

I've tried stuff like this: How to remove or identify unused packages from flutter to reduce size of the project?

clearing out the pubspeck.lock files, .pub-cache folder, flutter clean flutter pub get everything. There is no reference in any files in my projects to 0.9.20 whatsoever, and all pubspec.yaml files have it pinned:

dependencies:
  serverpod_client: ^0.9.8

So where is flutter getting 0.9.20 from? or even more importantly how do I just clear it all out?

the weird thing is, if I re-clone it and run dart pub get then look at the pubspeck.lock it creates it shows

  serverpod_client:
    dependency: "direct main"
    description:
      name: serverpod_client
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.9.20"

even though the pubspec.yaml clearly pins it at 0.9.8 this tells me that the issue isn't in the project or repo or it's cache, but in my actual flutter installation somehow... flutter's cache?

Here's a extended version of the error:

Launching lib\main.dart on sdk gphone x86 in debug mode...
lib\main.dart:1
: Error: Type 'ServerpodClientErrorCallback' not found.
../…/protocol/client.dart:72
      ServerpodClientErrorCallback? errorHandler,
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: Error: The non-abstract class 'Consent' is missing implementations for these members:
package:ravencoin_back/…/protocol/consent_class.dart:14
 - SerializableEntity.toJson
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class Consent extends SerializableEntity {
      ^^^^^^^
/C:/Users/j/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/serverpod_serialization-0.9.20/lib/src/serialization.dart:21:11: Context: 'SerializableEntity.toJson' is defined here.
  dynamic toJson();
          ^^^^^^
: Error: The non-abstract class 'ConsentDocument' is missing implementations for these members:
package:ravencoin_back/…/protocol/consent_document_class.dart:14
 - SerializableEntity.toJson
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

In terminal to clean cache run dart pub cache clean to clean packages in project build, flutter clean

More info: https://dart.dev/tools/pub/cmd/pub-cache

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM