title: How to fix Flutter Expected a value of type 'Map<String, dynamic>', but got one of type 'List<dynamic>'
body: <p>I'm developing a web app using Flutter Web and RESTful API for backend.
  So, I'm trying the fetch the data from the api, serialize it by using Flutter Models, then return the result.</p>
  <p>The Problem is, I'm getting this result</p>
  <pre><code>Expected a value of type 'Map&lt;String, dynamic&gt;', but got one of type 'List&lt;dynamic&gt;'
  </code></pre>
  <p>How to fix this ?</p>
  <p>Here's my flutter codes:</p>
  <p><strong>models</strong></p>
  <pre><code>// To parse this JSON data, do
  //
  //     final medicalRecordsModel = medicalRecordsModelFromJson(jsonString);
  
  import 'dart:convert';
  
  class MedicalRecordsModel {
    MedicalRecordsModel({
      this.id,
      this.category,
      this.fileName,
      this.dateTimestamp,
      this.description,
      this.upload,
      this.patientName,
      this.age,
      this.address,
      this.userId,
      this.patientId,
      this.isActive,
    });
  
    final String id;
    final String category;
    final String fileName;
    final String dateTimestamp;
    final String description;
    final String upload;
    final String patientName;
    final String age;
    final String address;
    final dynamic userId;
    final int patientId;
    final bool isActive;
  
    factory MedicalRecordsModel.fromJson(Map&lt;String, dynamic&gt; json) {
      return MedicalRecordsModel(
        id: json[&quot;id&quot;],
        category: json[&quot;category&quot;],
        fileName: json[&quot;fileName&quot;],
        dateTimestamp: json[&quot;dateTimestamp&quot;],
        description: json[&quot;description&quot;],
        upload: json[&quot;upload&quot;],
        patientName: json[&quot;patientName&quot;],
        age: json[&quot;age&quot;],
        address: json[&quot;address&quot;],
        userId: json[&quot;userId&quot;],
        patientId: json[&quot;patientId&quot;],
        isActive: json[&quot;isActive&quot;],
      );
    }
  }
  
  </code></pre>
  <p><strong>API Connection</strong></p>
  <pre><code>import 'dart:convert';
  import 'dart:developer';
  import 'dart:async';
  import 'package:app/src/constants/medical_records.dart';
  import 'package:app/src/models/medical_records/medical_records.dart';
  import 'package:app/src/pages/Medical-Records/medical_record.dart';
  import 'package:http/http.dart' as http;
  
  class MedicalRecordsManager {
    var client = http.Client();
    var url = ConstantMedicalRecords.medical_records_api;
  
    Future&lt;MedicalRecordsModel&gt; getRecords() async {
      var url = ConstantMedicalRecords.medical_records_api;
      log('$url');
      try {
        final response = await client.get(url);
        if (response.statusCode == 200) {
          return MedicalRecordsModel.fromJson(jsonDecode(response.body));
          // print(recordsModel);
        }
      } catch (Exception) {
        print(Exception);
        print(&quot;Error occured&quot;);
      }
    }
  }
  
  
  </code></pre>
  <p>Here is the JSON data I want to get</p>
  <pre><code> {
          &quot;id&quot;: &quot;103&quot;,
          &quot;category&quot;: &quot;DOCUMENT&quot;,
          &quot;fileName&quot;: &quot;Check Up&quot;,
          &quot;dateTimestamp&quot;: &quot;2021-02-1012:59:46&quot;,
          &quot;description&quot;: &quot;string&quot;,
          &quot;upload&quot;: &quot;String&quot;,
          &quot;patientName&quot;: &quot;1&quot;,
          &quot;age&quot;: &quot;25&quot;,
          &quot;address&quot;: &quot;Earth&quot;,
          &quot;userId&quot;: null,
          &quot;patientId&quot;: 12,
          &quot;isActive&quot;: true
      }
  </code></pre>
  <p>Please help me with this one.</p>