parseDevice method
Parse a Device from the userAgent string.
Returns null if no match.
Implementation
Device? parseDevice(String userAgent) {
for (DeviceParser deviceParser in deviceParsers) {
for (String regex in deviceParser.regexes) {
RegExp regExp = RegExp(regex, caseSensitive: false);
if (regExp.hasMatch(userAgent)) {
return Device(
type: deviceParser.type,
vendor: deviceParser.vendor,
model: deviceParser.model,
parsedWithRegex: regex,
);
}
}
}
return null;
}