scanProduct static method
Opens camera app to scan QR code
returns ProductScanResult if a product is found matching the UPC Code.
Implementation
static Future<ProductScanResult?> scanProduct() async {
final result = await BarcodeScanner.scan();
if (result.rawContent.isNotEmpty) {
logger.verbose("[DEBUG] Scanned: ${result.rawContent}");
final product = await Product.getProductByUPCCode(
upcCode: result.rawContent,
);
if (product != null) {
return ProductScanResult(
product: product,
);
}
}
return null;
}