how to clean flutter outdated pubs

Viewed 3043

As the image show, there are several versions of same pubs in my local:

  • .pub-cache/hosted/pub.dartlang.org/some-version1.
  • .pub-cache/hosted/pub.dartlang.org/some-version2.
  • .pub-cache/hosted/pub.dartlang.org/some-version3.
  • .pub-cache/hosted/pub.dartlang.org/some-version4.

Is there a way to clean them ? Or clean them by provide a minimal dart version. (like mini dart > 2.6.0) ?

enter image description here

2 Answers

I don't think there is a command for that. Because pub cannot know whether you have an old project lying around that depends on one of these older package versions or not.

The easiest way to clean away old packages is to just delete .pub-cache altogether. When you first run flutter pub get the ones that you actually use will be re-downloaded. This would get rid of the unused ones.

flutter 1.17 provided a new commend: flutter pub outdated. which have good progress on this.

Related