primary method
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.
Implementation
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;
}