title: Error: List<dynamic> is not a subtype of type Map<String, dynamic> Future Builder
body: <p>I am currently trying to generate a FutureBuilder gridView but no matter what I do it keeps getting the error: List is not a subtype of type Map&lt;String, dynamic&gt;, I've tried most of the stack suggestions for those who had similar errors but none of them worked.</p>
  <p>shop.dart</p>
  <pre><code>@freezed
  class Shop with _$Shop {
    factory Shop({
      int? id,
      String? name,
      String? logo,
      Location? location,
    }) = _Location;
    factory Location.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$LocationFromJson(json);
  
    static Location fromJsonModel(Map&lt;String, dynamic&gt; json) =&gt; Location.fromJson(json);
  }
  </code></pre>
  <p>shop_service.dart</p>
  <pre><code>class ShopService extends BaseHttpService {
    final AppContext appContext;
    late String _shopApi;
  
    ShopService(http.Client client, this.appContext) : super(httpClient: client) {
      _shopApi = '${Globals.ApiEndpoint}/user/${appContext.currentCustomer.id}/shops/';
    }
  
     Future&lt;List&lt;Shop&gt;&gt; fetch() async {
      var token = await this.appContext.currentUser!.getIdToken();
      final response = await callApi(_shopApi, token); //response = response.body from http handler
      List jsonResponse = json.decode(response); // also tried List jsonMap = json.decode(response).cast&lt;Map&lt;String, dynamic&gt;&gt;();
      return jsonResponse.map((item) =&gt; new Shop.fromJson(item)).toList();
    }
  }
  </code></pre>
  <p>shop_screen.dart</p>
  <pre><code>class _ShopTabScreenState extends State&lt;ShopTabScreen&gt; {
    late ShopService _shopService;
  
    @override
    void initState() {
      _shopService = svcContainer&lt;shopService&gt;();
  
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return Column(
        children: &lt;Widget&gt;[
          Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              SizedBox(
                height: 15.0,
              ),
              Padding(
                padding: const EdgeInsets.only(left: 30.0, right: 30.0),
                child: InputField(
                  obscureText: false,
                  hintText: 'text',
                  prefixIcon: Icon(Icons.search),
                ),
              ),
              SizedBox(
                height: 15.0,
              ),
              Text(
                'Participating Shop',
                textAlign: TextAlign.center,
              ),
            ],
          ),
          SizedBox(
            height: 5.0,
          ),
          Expanded(
            child: FutureBuilder(
              future: _shopService.fetch(),
              builder: (BuildContext context, AsyncSnapshot&lt;List&lt;Shop&gt;&gt; snapshot) {
                if (snapshot.hasData) {
                  final content = snapshot.data!;
                  return gridViewBuild(content);
                } else if (snapshot.hasError) {
                  return Center(child: Text('Error: ${snapshot.error}'));
                }
  
                return Center(child: CircularProgressIndicator());
              },
              // child: SizedBox(
              //   height: 100.0,
              //   child:
              // ),
            ),
          ),
          SizedBox(
            height: 10.0,
          ),
        ],
      );
    }
  
    void _refresh(String shopId) {
        setState(() {});
    }
  
    Widget gridViewBuild(List&lt;Shop&gt; data) {
      return Padding(
        padding: const EdgeInsets.all(20.0),
        child: new GridView.builder(
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisCount: 3, crossAxisSpacing: 10, childAspectRatio: (1 / 0.75), mainAxisSpacing: 10),
            itemCount: data.length,
            itemBuilder: (BuildContext context, int index) {
              if (data[index].shop != null) {
                return new LocationYes(
                    shopImg: data[index].logo,
                    shopId: data[index].id.toString(),
                    shopName: data[index].name);
              } else {
                return new LocationdNo(
                    shopImg: data[index].logo,
                    shopId: data[index].id.toString(),
                    shopName: data[index].name);
                    newLocationCallback: _refresh);
              }
              return new Container();
            }),
      );
    }
  }
  }
  </code></pre>
  <p>Json Response</p>
  <pre><code>[
      {
          &quot;id&quot;: 1,
          &quot;name&quot;: &quot;test1&quot;,
          &quot;logo&quot;: &quot;test1.png&quot;,
          &quot;location&quot;: [
              {
                  &quot;id&quot;: &quot;123&quot;,
                  &quot;locationNumber&quot;: &quot;testloc1&quot;,
                  &quot;created&quot;: &quot;2021-12-06T06:09:38.762Z&quot;,
                  &quot;updated&quot;: &quot;2021-12-06T06:09:16.076Z&quot;
              }
          ]
      },
      {
          &quot;id&quot;: 2,
          &quot;name&quot;: &quot;test2&quot;,
          &quot;logo&quot;: &quot;test2.jpg&quot;,
          &quot;location&quot;: [
              {
                  &quot;id&quot;: &quot;123&quot;,
                  &quot;locationNumber&quot;: &quot;testloc2&quot;,
                  &quot;created&quot;: &quot;2021-12-06T06:09:38.762Z&quot;,
                  &quot;updated&quot;: &quot;2021-12-06T06:08:50.607Z&quot;
              }
          ]
      },
      {
          &quot;id&quot;: 3,
          &quot;name&quot;: &quot;test3&quot;,
          &quot;logo&quot;: &quot;test3.png&quot;,
          &quot;location&quot;: []
      }
  ]
  </code></pre>
  <p>Error is thrown in this section</p>
  <pre><code>child: FutureBuilder(
              future: _shopService.fetch(),
              builder: (BuildContext context, AsyncSnapshot&lt;List&lt;Shop&gt;&gt; snapshot) {
                if (snapshot.hasData) {
                  final content = snapshot.data!;
                  return gridViewBuild(content);
                } else if (snapshot.hasError) {
                  return Center(child: Text('Error: ${snapshot.error}'));
                }
  </code></pre>
  <p><strong>UPDATE:</strong> I've done some more debugging and I see some stack trace errors</p>
  <p><code>return jsonResponse.map((item) =&gt; new Shop.fromJson(item)).toList();</code></p>
  <p>Below is the shop.g.dart file from freeze generated where I can see the stack trace error starts.</p>
  <pre><code>_$_Shop _$$_ShopFromJson(Map&lt;String, dynamic&gt; json) =&gt; _$_Shop(
        id: json['id'] as int?,
        name: json['name'] as String?,
        logo: json['logo'] as String?,
        location: json['location'] == null
            ? null
            : location.fromJson(json['location'] as Map&lt;String, dynamic&gt;),
      );
  
  Map&lt;String, dynamic&gt; _$$_ShopToJson(_$_Shop instance) =&gt;
      &lt;String, dynamic&gt;{
        'id': instance.id,
        'name': instance.name,
        'logo': instance.logo,
        'location': instance.location,
      };
  </code></pre>
  <p>This is the line where error starts:</p>
  <pre><code>: location.fromJson(json['location'] as Map&lt;String, dynamic&gt;),
  </code></pre>
  <p>Additionlly for completeness this is the location model which is also freeze generaeted.</p>
  <pre><code>@freezed
  class Location with _$Location {
    factory Location({
        String? id,
        @JsonKey(name: 'locationNumber')String? number,
        @JsonKey(name: 'created') String? createdAt,
        @JsonKey(name: 'updated') String? updatedAt,
        String? shop}) = _Location;
  
    factory Location.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$LocationFromJson(json);
  
    static Location fromJsonModel(Map&lt;String, dynamic&gt; json) =&gt; Location.fromJson(json);
  }
  </code></pre>