ComparableVersion class
A parsed semantic version that supports full ordering.
Only the strict three-part major.minor.patch format is accepted. All
integer parts must be non-negative. Pre-release and build-metadata
suffixes (e.g. -rc1, +build.1) are not supported and will cause
a FormatException.
Version objects are immutable. Comparison is lexicographic on the
(major, minor, patch) tuple.
Example:
final v = ComparableVersion('1.41.0');
assert(v > ComparableVersion('1.40.0'));
assert(v == '1.41.0');
- Implemented types
Constructors
- ComparableVersion(String version)
-
Creates a ComparableVersion by parsing
version.factory
Properties
- hashCode → int
-
Returns a hash code consistent with operator ==.
no setteroverride
- major → int
-
The major version component.
final
- minor → int
-
The minor version component.
final
- patch → int
-
The patch version component.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
compareTo(
ComparableVersion other) → int -
Compares this version to
other.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Returns the canonical version string, e.g.
'1.2.3'.override
Operators
-
operator <(
Object other) → bool -
Returns
trueif this version is strictly less thanother. -
operator <=(
Object other) → bool -
Returns
trueif this version is less than or equal toother. -
operator ==(
Object other) → bool -
Returns
trueif this version is equal toother.override -
operator >(
Object other) → bool -
Returns
trueif this version is strictly greater thanother. -
operator >=(
Object other) → bool -
Returns
trueif this version is greater than or equal toother.