toString method
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse
function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString
to provide
useful information when inspecting the object,
mainly for debugging or logging.
Implementation
@override
String toString() {
var buffer = StringBuffer();
final min = this.min;
if (min != null) {
buffer
..write(includeMin ? '>=' : '>')
..write(min);
}
final max = this.max;
if (max != null) {
if (min != null) buffer.write(' ');
if (includeMax) {
buffer
..write('<=')
..write(max);
} else {
buffer.write('<');
if (max.isFirstPreRelease) {
// Since `"<$max"` would parse the same as `"<$max-0"`, we just emit
// `<$max` to avoid confusing "-0" suffixes.
buffer.write('${max.major}.${max.minor}.${max.patch}');
} else {
buffer.write(max);
// If `">=$min <$max"` would parse as `">=$min <$max-0"`, add `-*` to
// indicate that actually does allow pre-release versions.
var minIsPreReleaseOfMax = min != null &&
min.isPreRelease &&
equalsWithoutPreRelease(min, max);
if (!max.isPreRelease && max.build.isEmpty && !minIsPreReleaseOfMax) {
buffer.write('-∞');
}
}
}
}
if (min == null && max == null) buffer.write('any');
return buffer.toString();
}