findByUpc method

Future<Map<String, dynamic>?> findByUpc(
  1. String upc
)

Looks up a product by its Universal Product Code (UPC).

Queries the apl collection in FirebaseFirestore using the upc as the document ID.

Returns a Map with product data (name, category, eligible, etc.) if found, or null if the product doesn't exist in the APL.

Example return value:

{
  'upc': '000000743266',
  'name': 'Whole Milk',
  'category': 'Milk',
  'eligible': true
}

Implementation

Future<Map<String, dynamic>?> findByUpc(String upc) async {
  final doc = await _db.collection('apl').doc(upc).get();
  if (!doc.exists) return null;
  return doc.data();
}