title: how to initialize a class when collecting data from db in firestore flutter provider
body: <p>I am following one tutorial on Flutter Ecommerce using Firestore and flutter provider. </p>
  
  <p>I wanted to retrieve all the data from firestore Db, but the problem is I don't know how to initialize the class I am going to use to retrieve data from Db firestore. Pls help. And if you have better approaches you can share your knowledge with me. this is the code below:</p>
  
  <pre><code> import 'package:flutter/material.dart';
  import 'package:shopping/db/product.dart';
  import 'package:shopping/models/product.dart';
  
   class AppProvider with ChangeNotifier {
     List&lt;Product&gt;_fearturedProducts=[];
     ProductService _productService=new ProductService();
  
     AppProvider(){
       //please how to initialize class AppProvider here 
   }
     //getter
     List&lt;Product&gt; get featuredProducts=&gt;_fearturedProducts;
  
     //method
     void _getFeaturedProducts()async{
  
      _fearturedProducts=await _productService.getFeaturedProducts();
      notifyListeners();
     }
   }
  </code></pre>
  
  <h2>code for ProductService class:</h2>
  
  <pre><code>import 'package:cloud_firestore/cloud_firestore.dart';
  import 'package:shopping/models/product.dart';
  
  class ProductService{
      Firestore _firestore=Firestore.instance;
    String collection="Products";
  
    Future&lt;List&lt;Product&gt;&gt;getFeaturedProducts(){
  
   _firestore.collection(collection).where('featured', isEqualTo:true).getDocuments()
   .then((snap){
  
    List&lt;Product&gt;featuredProducts=[];
     snap.documents.map((snapshot)=&gt; featuredProducts.add(Product.fromSnapshot(snapshot)));
     return featuredProducts;
   }); 
  
  }
  
  }
  </code></pre>