How to install an updated version of the Dart package?

When a new Dart package is published, how can I install an updated version?

+7
install dart updates package-managers dart-pub
source share
2 answers

DartEditor automatically calls pub get when the pubspec.yaml file is pubspec.yaml .

You can call it manually (for example, when, for example, you checked a project from GitHub without changing any file)

  • using the pub get context menu in DartEditor in the pubspec.yaml file
  • by invoking pub get at a command prompt in the package directory where the pubspec.yaml file is pubspec.yaml .

pub get downloads the version of the package specified in the pubspec.lock file (in the root directory of the package), or the latest version that matches your version restriction ( 0.0.1 in your example could be any for 'most recent') if pubspec.lock does not exist. pub get / pub upgrade create a pubspec.lock file if it does not already exist and save the versions of downloaded packages that it just downloaded.

Check for package updates and download them using

  • pub upgrade context menu in DartEditor in pubspec.yaml file
  • pub upgrade at a command prompt in the package directory where the pubspec.yaml file is pubspec.yaml .

pub upgrade downloads the latest version that meets your version restrictions and saves the downloaded version in the pubspec.lock file.

pub get / pub upgrade prefers stable releases (version numbers that do not contain - ), such as 0.0.1 or 1.2.0+1 over preliminary releases, such as 0.0.2-1 or 1.2.1-1 , if any which fulfills your version restriction.

If you need a pre-release, you need to tighten the version limit so that only the pre-release will comply with your restrictions (e.g. angular: '>=1.2.1' )

pub upgrade can show output like

analyzer 0.10.5 (9 new versions available)

This means that there are 9 pre-release versions available that are newer than the loaded stable build.

The version limit for your dependency should match the version restrictions of all dependency dependencies (for example, if you add observe and polymer dependencies, where polymer depends on observe itself).

You can force pub get / pub upgrade version that breaks dependency dependency by defining a dependency with a version constraint in dependencies_override: instead of dependencies: in pubspec.yaml .

You can also add dev_dependencies (e.g. unittest ) that load only when they are defined in your package, but are ignored when they are defined in only one of your dependencies.

You see, this is an advanced topic even for experienced Dart developers.

+7
source share

If you are an experienced Dartian, this question may seem so trifling that it should not be asked, but comes from the Java world (where my students and I are used to downloading .jars manually and then (sometimes) copying them to our projects), this is a natural question which is natural to ask. Here's the context: two days ago v0.9.5 came out of angular, so I took a note to load the libraries into our local projects.

Well, it looks like we only need the corresponding pubspec.yaml file, and the Dart pub manager does the rest. In the Dart editor, I assume that the dependencies are updated in the project update or when it is (re) built. In our projects, for example, we had the pubspec.yaml file:

 name: angular_dart_demo version: 0.0.1 dependencies: angular: any 

(unlike, say, angular: ">=0.9.0 <0.10.0" ), which allowed the Pub manager to get the latest angular . Effortless Nice.

+5
source share

All Articles