getProducts method

Stream<List<Product>> getProducts(
  1. String farmerId
)

Retrieves a stream of products for a specific farmer from Firestore.

Parameters:

  • farmerId: The ID of the farmer whose products are to be fetched.

Returns: A Stream<List<Product>> containing the farmer's products.

Implementation

Stream<List<Product>> getProducts(String farmerId) {
  return _firestore
      .collection('products')
      .where('farmerId', isEqualTo: farmerId)
      .snapshots()
      .map((snapshot) => snapshot.docs
          .map((doc) => Product.fromMap(doc.data(), doc.id))
          .toList());
}