The version constraint

The version constraint can be a concrete version number, a range, or a minimum or maximum constraint. Let's explore how it looks in each situation:

  • Any/empty: Like the previous example, we can use this without a version constraint, for example, json_serializable: or json_serializable: any.
  • Concrete version: We can add the specific version number we want to work with, for example, json_serializable: 2.0.1.
  • Minimal bound: Here, we can add a minimum acceptable version of the package we want in two ways: json_serializable: '>1.0.0', where we accept any version later than the specified version (excluding the specified one), or json_serializable: '>=1.0.0', where we accept any version above or equal to the specified version.
  • Maximal bound: Like the previous minimum example but in the upper bound, we can add a maximum acceptable version of the package that we want in two ways: json_serializable: '<2.0.1', where we accept any version below the specified one, or json_serializable: '<=2.0.1', where we accept any version below or equal to the specified one.
  • Range: By combining minimal and maximal bounds, we can specify an acceptable interval of versions: json_serializable: '>1.0.0 <=2.0.1'json_serializable: '>1.0.0 <2.0.1'json_serializable: '>=1.0.0 <2.0.1', or json_serializable: '>=1.0.0 <=2.0.1'.
  • Semantic range: This is similar to range but, by using the caret character, we can specify the range from a minimum acceptable version to the next breaking change. For example, json_serializable: ^1.0.0 is the same as json_serializable: '>=1.0.0 <2.0.0', and json_serializable: ^0.1.0 is equal to json_serializable: '>=0.1.0 <0.2.0'.
Semantic versioning helps the community usage of the libraries and it is widely adopted. To examine it in more detail, you can visit the pub tools page at https://www.dartlang.org/tools/pub/versioning.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.83.240