withTerseConstraint method
Returns a copy of this
with the same semantics, but with a ^
-style
constraint if possible.
Implementation
PackageRange withTerseConstraint() {
if (constraint is! VersionRange) return this;
if (constraint.toString().startsWith('^')) return this;
final range = constraint as VersionRange;
if (!range.includeMin) return this;
if (range.includeMax) return this;
final min = range.min;
if (min == null) return this;
if (range.max == min.nextBreaking.firstPreRelease) {
return PackageRange(_ref, VersionConstraint.compatibleWith(min));
} else {
return this;
}
}