How to specify dependency_overrides in pubspec.yam

2019-06-02 06:00发布

问题:

I am working with latest version of angular.dart and my pubspec.yaml looks somewhat like this:

name: angularApp
dependencies:
  angular:
    git:  'git@github.com:angular/angular.dart'
  third_party_angular_plugin: any

the problem is third_party_angular_plugin is depending on stable version of angular.dart. I tried to specify as follows:

name: angularApp
dependencies:
  angular:
    git:  'git@github.com:angular/angular.dart'
  third_party_angular_plugin: any
dependency_overrides:
  angular:
    version: ">=0.9.10"

But it throws a weird error saying Bad State: No elements dart:core List.single ....

How can I override third_party_angular_plugin's dependency on angular for my app?

回答1:

The version is not a separate nested key, as per the example on Pub Dependencies page, the right format is this:

name: angularApp
dependencies:
  angular:
    git:  'git@github.com:angular/angular.dart'
  third_party_angular_plugin: any
dependency_overrides:
  angular: ">=0.9.10"