title: How to get array list of maps from Firebase with ModelClass
body: <p><strong>SOLUTION ADDED BELOW</strong></p>
  <p>I would like to model this Firebase document format with in my ServiceModel which it is in SalonModel.</p>
  <p>Actually, I can model whole fields for SalonModel but whenever I tried to model ServiceModel it is not working.</p>
  <p>Firebase document screenShot:</p>
  <p><a href="https://i.stack.imgur.com/TG6Ra.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TG6Ra.png" alt="enter image description here" /></a></p>
  <p>Here is some part of SalonModel:</p>
  <pre><code>class SalonModel {
   String? uid;
   String? name;
  SalonServices? salonServices;
  SalonModel({this.uid, this.name, this.salonServices})
  
  factory SalonModel.fromMap(Map&lt;String, dynamic&gt; map) {
      return SalonModel(
        uid: map['uid'],
        name: map['name'],
        salonServices: map['salonServices'] != null
            ? SalonServices.fromMap(map['salonServices'])
            : null,
      );
  
  
  }
  </code></pre>
  <p>And here is my SalonServicesClass:</p>
  <pre><code>class SalonServices {
    String? serviceName;
    String? serviceDescription;
    bool? isActive;
    int? servicePrice;
    int? serviceDiscount;
    SalonServices({
      this.serviceName,
      this.serviceDescription,
      this.isActive,
      this.servicePrice,
      this.serviceDiscount,
    });
  
    Map&lt;String, dynamic&gt; toMap() {
      return {
        'serviceName': serviceName,
        'serviceDescription': serviceDescription,
        'isActive': isActive,
        'servicePrice': servicePrice,
        'serviceDiscount': serviceDiscount,
      };
    }
  
    factory SalonServices.fromMap(Map&lt;String, dynamic&gt; map) {
      return SalonServices(
        serviceName: map['serviceName'],
        serviceDescription: map['serviceDescription'],
        isActive: map['isActive'],
        servicePrice: map['servicePrice']?.toInt(),
        serviceDiscount: map['serviceDiscount']?.toInt(),
      );
    }
  }
  </code></pre>
  <p>And with this fucntion, I am modeling these fields:</p>
  <pre><code>Future&lt;SalonModel&gt; fetchMyDatas(String uid) async {
      var doc =
          await FirebaseFirestore.instance.collection('salons').doc(uid).get();
  
      Map&lt;String, dynamic&gt;? docData = doc.data();
      return SalonModel.fromMap(docData!);
    }
  </code></pre>
  <p>Then this function returning me this error:</p>
  <blockquote>
  <p>Unhandled Exception: type 'List' is not a subtype of type
  'Map&lt;String, dynamic&gt;'</p>
  </blockquote>
  <p>If we go to where the exception by thrown, we'll see this line is not working in SalonModel.fromMap:</p>
  <pre><code> salonServices: map['salonServices'] != null
            ? SalonServices.fromMap(map['salonServices'])
            : null,
  </code></pre>
  <p>What can I do in this situation ?</p>
  <p><em><strong>UPDATE</strong></em></p>
  <p>I can't map it. There is no option.
  <a href="https://i.stack.imgur.com/MFx4O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MFx4O.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/KCFqE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KCFqE.png" alt="enter image description here" /></a></p>
  <p><em><strong>HERE IS MY SOLUTION</strong></em></p>
  <p>In SalonModel class;</p>
  <pre><code>  List&lt;SalonServices&gt;? salonServices;
  </code></pre>
  <p>Then inside of SalonModel.fromMap method:</p>
  <pre><code>...
       salonServices: json['salonServices'] == null
                  ? null
                  : List&lt;SalonServices&gt;.from(
                      json['salonServices'].map((x) =&gt; SalonServices.fromMap(x)))
  </code></pre>
  <p>And our fetchMyDatas works well finally.</p>