parse method
Attempts to parse the raw Result's contents as a particular type of information (email, URL, etc.) and return a ParsedResult encapsulating the result of parsing.
@param theResult the raw Result to parse @return ParsedResult encapsulating the parsing result
Implementation
@override
VINParsedResult? parse(Result result) {
if (result.barcodeFormat != BarcodeFormat.code39) {
return null;
}
String rawText = result.text;
rawText = rawText.replaceAll(_ioq, '').trim();
if (!_az09.hasMatch(rawText)) {
return null;
}
try {
if (!_checkChecksum(rawText)) {
return null;
}
final wmi = rawText.substring(0, 3);
return VINParsedResult(
vin: rawText,
worldManufacturerID: wmi,
vehicleDescriptorSection: rawText.substring(3, 9),
vehicleIdentifierSection: rawText.substring(9, 17),
countryCode: _countryCode(wmi),
vehicleAttributes: rawText.substring(3, 8),
modelYear: _modelYear(rawText.codeUnitAt(9)),
plantCode: rawText.codeUnitAt(10),
sequentialNumber: rawText.substring(11),
);
} on ArgumentError catch (_) {
// IllegalArgumentException
return null;
}
}