reportDocumentVersion function
Implementation
DocumentVersionReport reportDocumentVersion(dynamic version) {
if (version is! String) {
return DocumentVersionReport(isSupported: false, raw: version);
}
final match = documentVersionPattern.firstMatch(version);
if (match == null) {
return DocumentVersionReport(isSupported: false, raw: version);
}
final major = int.tryParse(match.group(1) ?? '');
final minor = int.tryParse(match.group(2) ?? '');
final supportedMajor = int.parse(uidlSpecVersion.split('.').first);
if (major == null || minor == null || major != supportedMajor) {
return DocumentVersionReport(
isSupported: false,
major: major,
minor: minor,
raw: version,
);
}
return DocumentVersionReport(
isSupported: true,
major: major,
minor: minor,
raw: version,
);
}