SemVer.parse constructor
SemVer.parse(
- String input
Implementation
factory SemVer.parse(String input) {
final regex = RegExp(
r'^(\d+)\.(\d+)\.(\d+)'
r'(?:-([0-9A-Za-z\-.]+))?'
r'(?:\+([0-9A-Za-z\-.]+))?$',
);
final match = regex.firstMatch(input);
if (match == null) {
throw FormatException('Invalid version. Must follow SemVer.');
}
return SemVer(
int.parse(match.group(1)!),
int.parse(match.group(2)!),
int.parse(match.group(3)!),
preRelease: match.group(4),
buildMetadata: match.group(5),
);
}