downgrade method
SemanticVersion
downgrade({})
inherited
Returns a new SemanticVersion
that is downgraded from this
.
At a minimum, the pre-release version will be removed. Other downgrades
can be applied by specifying any of downgradeMajor
, downgradeMinor
,
and downgradePatch
, which will decrement the value of their respective
version part by one (unless the value is already 0).
This method may return a version equal to this
if no downgrade options
are specified.
Implementation
SemanticVersion downgrade({
bool downgradeMajor = false,
bool downgradeMinor = false,
bool downgradePatch = false,
}) {
var major = this.major;
var minor = this.minor;
var patch = this.patch;
if (downgradeMajor) {
major = math.max(0, major - 1);
}
if (downgradeMinor) {
minor = math.max(0, minor - 1);
}
if (downgradePatch) {
patch = math.max(0, patch - 1);
}
return SemanticVersion(
major: major,
minor: minor,
patch: patch,
);
}