Question

When making a package, I am often confused as to whether I should use the any constraint.

I know that for:

but there is a grey area for:

  • applications that are meant to be extended, such as codelabs, tutorials, templates, examples, and others.

  • applications that also have re-usable libraries; that is, packages that have a lib directory for common functionality that doesn't make sense to put in a separate package, but also a web directory for a full-fledged application.


Question: When exactly should I use the any version constraint, and when should I fully specify the version constraint for Pub packages?

Était-ce utile?

La solution

applications that are meant to be extended, such as codelabs, tutorials, templates, examples, and others.

Since these are often going to be copy-pasted as the basis of normal application packages, I'd use the any constraint and check in a lockfile to set a good example.

applications that also have re-usable libraries; that is, packages that have a lib directory for common functionality that doesn't make sense to put in a separate package, but also a web directory for a full-fledged application.

All applications should put their code in the lib directory. The web directory should just contain the entrypoint(s). So this is just a standard application package, which should use the any constraint and check in a lockfile.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top