In pubspec.lock, what is a "direct main" dependency?

Asked

Viewed 71 times

4

In Dart, we specify dependencies through pubspec.yaml through indicators of the desired version (similar to gemfile for Ruby or the composer.json for PHP). From this list of dependencies and versions, the Dart SDK itself works to compile this information for what is in fact wearing, currently. The result of this compilation is the file pubspec.lock.

It is recommended (by documentation of Dart himself), in libraries, do not submit this file to the version system; on the other hand, to applications, the recommendation is go up that file, so that all developers get the same dependency on that point of code.

Doing maintenance on an application, I noticed that there was a change in the pubspec.lock: an addiction ceased to be "transitive" to be "direct main".

Example of dependency transitive/direct main:

packages:
  _fe_analyzer_shared:
    dependency: transitive
    description:
      name: _fe_analyzer_shared
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.0"
  analyzer:
    dependency: "direct main"
    description:
      name: analyzer
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.39.1"

My question is: what differs a dependency transitive of a direct main?

1 answer

4


Let’s assume that in your pubspec.yaml you make clear the need for two dependencies:

Dependencia_A: '<3.0.0'
Dependencia_B: '<3.0.0'

It means that these two dependencies are necessary directly by your code. You requested and your installation was marked as required by you.

Dependencies of this type will be marked as direct main.

Now, supposing that the Dependencia_A also needs the Dependencia_C, this dependency should also be installed, but it originated transitive. I mean, it’s not a direct dependency on your code.

Dependencies of this type will be marked as transitive.

From the site Linkei, freely translated:

If your package depends on A, which in turn depends on B, which depends on C, then A is an immediate dependency while B and C are transitive dependencies.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.