primary method

Version primary (List<Version> versions)

Returns the primary version out of a list of candidates.

This is the highest-numbered stable (non-prerelease) version. If there are no stable versions, it's just the highest-numbered version.


static Version primary(List<Version> versions) {
  var primary;
  for (var version in versions) {
    if (primary == null ||
        (!version.isPreRelease && primary.isPreRelease) ||
        (version.isPreRelease == primary.isPreRelease && version > primary)) {
      primary = version;
  return primary;