Dart any dependency usage in pubspec.yaml for multi module project

Viewed 196

I need something similar in Dart to what Maven has with a parent-pom dependencyManagement structure.

I have 2 modules in Dart, api and core.

api/pubspec.yaml:

...
dependencies:
  http: '>=0.12.0 <0.13.0'
  meta: '>=1.0.0 <2.0.0'
...

core/pubspec.yaml:

...
dependencies:
  api:
    path: ../api
  # Meta is added again with a version number
  meta: '>=1.0.0 <2.0.0'
  redux: '4.0.0'
...

So if I change the dependencies in core/pubspec.yaml to 'any' if they already exist in api/pubspec.yaml:

...
dependencies:
  api:
    path: ../api
  # No version number is needed, the exact version will come from the dependency
  meta: 'any'
  redux: '4.0.0'
...

This seems to be working, but the official site does not mention this feature, instead:

The string any allows any version. This is equivalent to an empty version constraint, but is more explicit. Although any is allowed, we don’t recommend it.

Is this an unintended good use case of the 'any' or this is a bad idea? (I am confident api dependency will always exist and declare meta, they are all my modules.)

0 Answers
Related