parse static method
Parse
Implementation
static VersionBoundaries parse(String text) {
var parts = text.trim().split(' ');
VersionBoundary? min;
VersionBoundary? max;
for (var part in parts) {
if (part.startsWith('>=')) {
try {
min = VersionBoundary(Version.parse(part.substring(2)), true);
} catch (_) {}
} else if (part.startsWith('>')) {
try {
min = VersionBoundary(Version.parse(part.substring(1)), false);
} catch (_) {}
} else if (part.startsWith('<=')) {
try {
max = VersionBoundary(Version.parse(part.substring(2)), true);
} catch (_) {}
} else if (part.startsWith('<')) {
try {
max = VersionBoundary(Version.parse(part.substring(1)), false);
} catch (_) {}
} else if (part.startsWith('^')) {
try {
min = VersionBoundary(Version.parse(part.substring(1)), true);
if (min.value.major != 0) {
max = VersionBoundary(Version(min.value.major + 1, 0, 0), false);
} else if (min.value.minor != 0) {
max = VersionBoundary(Version(0, min.value.minor + 1, 0), false);
} else {
max = VersionBoundary(Version(0, 0, min.value.patch + 1), false);
}
} catch (_) {}
} else {
try {
min = max = VersionBoundary(Version.parse(part), true);
} catch (_) {}
}
}
return VersionBoundaries(min, max);
}