7

I am coming from the Java world to the Dart world and in Java I could easily see the size of a .jar file. Sometimes I want one functionality from a package, but if the package is too big it doesn't justifies including all that extra code into my app.

How can I see the size of a pub package?

Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173

2 Answers2

6

I'm not sure if the size of the given archive matches exactly the size of the included pub dependency, but it might give you a direction: Take a look at the "Version" tab of the library on pub.dev (e.g. https://pub.dev/packages/http/versions). You can download the package as .tar.gz, which will show you the size. Maybe this helps?

Tidder
  • 1,126
  • 1
  • 7
  • 15
6

Dart comes with a Tree Shaker algorithm that will remove all unused code in release mode, reducing the size of your app to only the minimum.

So there's no real comparison with java and the jar size. Only the code you use will be added to your application.

Muldec
  • 4,641
  • 1
  • 25
  • 44
  • 2
    But this still does not answer the question – rsanath Nov 15 '20 at 12:47
  • Well, it says that the size of the package is irrelevant, only the portion of code you use is relevant. Therefore, the size is not something that is finite but depends on your usage. – Muldec Nov 16 '20 at 14:53
  • what if i have two plug in with same purpose & performance but have size differences ? – John vinith Jun 14 '22 at 04:51
  • It seems that tree shaking might only take place on certain platforms: https://stackoverflow.com/questions/65592503/does-flutter-perform-tree-shaking-dart-dead-code-elimination-for-android-i – Big_Chair Apr 14 '23 at 08:39