Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between `flutter packages get` and `flutter pub get`?

I just upgraded Android Studio and saw flutter packages get changed to flutter pub get in "Tools > Flutter".

Does this have any change in the functionality? Or are they completely the same?

like image 260
dmjy Avatar asked Apr 05 '20 02:04

dmjy


4 Answers

They both do the same thing. To prove this I created two exact same new projects and added exact dependencies

dependencies:
  image_picker: ^0.6.4

Now in one of the project I ran the command flutter pub get and in another one flutter packages get , both of them in verbose mode to check what is happening behind the scenes.

I could see logically no difference at all except those time taken to execute(which doesn't matter). The rest of the contents in the file as exactly the same.

So yes, they are doing the same thing

enter image description here

like image 168
Chetan Avatar answered Oct 12 '22 17:10

Chetan


They are the same.

flutter packages used to support only two subcommands including flutter packages get, but more commands were added later on.

And then, flutter packages was renamed to flutter pub. The former is now just an alias for the latter.

flutter packages get was not affected by the first change as it had already existed at that point, and its functionality has not been affected by the second change either as it was just a rename.

like image 13
kaboc Avatar answered Oct 12 '22 18:10

kaboc


The pub command is specific to dart and is a set of tools for managing dart packages. You can get an explanation about it and its usage here.

pub get is shorthand for the pub get packages which is how packages are downloaded in dart projects. Adding the flutter keyword before it makes it so that the command is run by the flutter SDK, which will map it to the sdk's packages get command. Reference

As for using the two, they can be used interchangeably as the Flutter SDK will automatically change flutter pub get to flutter packages get inside flutter projects, and I imagine the change in Android studio is semantic in nature to make it more inline with typical dart style as dart developers will be used to running pub get.

like image 5
Jwildsmith Avatar answered Oct 12 '22 17:10

Jwildsmith


When "flutter packages get" is executed, you will see

Running "flutter pub get" in xxx...

The two commands achieve the same results.

like image 1
1DD Avatar answered Oct 12 '22 17:10

1DD