title: How to make a Model Class Within Model Class (Flutter / Dart)
body: <p>I am trying to make a multivendor app with Flutter.
  The problem I am facing right now is how can I make a model class within a Model class:</p>
  <p><strong>Example:</strong></p>
  <pre class="lang-dart prettyprint-override"><code>class ProductModel {
  String? name;
  double? price;
  String? imgUrl;
  double? weight;
  
  ProductModel();
  
  ProductMode.fromSnapShot(DocumentSnapshot snapshot){
  name = snapshot['name'];
  price= snapshot['price'];
  imgUrl= snapshot['imgUrl'];
  weight= snapshot['weight'];
  }
  }
  </code></pre>
  <p>I have already retrieved all the products from <code>Firestore</code>:</p>
  <pre class="lang-dart prettyprint-override"><code>class VendorModel{
  String? name;
  String? imgUrl;
  DateTime? opensAt;
  DateTime? closesAt;
  
  
  VendorModel();
  
  VendorModel.fromSnapshot(DocumentSnapshot snapshot){
  name = snapshot['name'];
  imgUrl= snapshot['imgUrl'];
  opensAt= DateTime.tryParse(snapshot['opensAt'].toString());
  closesAt= DateTime.tryParse(snapshot['closesAt'].toString());
  }
  }
  </code></pre>
  <p><strong>I have also retrieved all the vendors from Firestore:</strong></p>
  <p>Here is What I am trying to do:
  I would like to add the products I fetched from <code>Firestore</code> to their respective vendors using this model. But I don't know how to make this if my data is from <code>Firestore</code>.</p>
  <pre class="lang-dart prettyprint-override"><code>class VendorWithProductsModel{
  VendorModel vendor;
  List&lt;ProductModel&gt; products;
  
  VendorWithProductsModel();
  (I AM STUCK HERE)
  }
  </code></pre>
  <p>Here is a Snippet of my <code>Firestore</code> code in retrieving products and vendors:</p>
  <pre class="lang-dart prettyprint-override"><code>VendorModel _vendor = VendorModel();
  List&lt;VendorModel&gt; _allVendors = [];
  
  Future&lt;VendorModel&gt; getCertainVendor(docId) async{
      await vendor.doc(docId).get().then((value){
        _vendor = VendorModel.fromSnapshot(value);
      });
      return _vendor;
    }
  Future&lt;List&lt;VendorModel&gt;&gt; getAllVendors() async{
      await vendor.get().then((value){
        _allVendors.add(VendorModel.fromSnapshot(value));
      });
      return _allVendors;
    }
  </code></pre>