title: Flutter - Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
body: <p>I'm trying to get an api, I can print the api response in the console. However, when I'm receive the respond to my model class, console shows and error like this</p>
  
  <blockquote>
    <p>E/flutter ( 9292): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)]
    Unhandled Exception: type 'String' is not a subtype of type 'int' of
    'index'</p>
  </blockquote>
  
  <p><strong>model.dart</strong></p>
  
  <pre><code>class CategoryDishes {
    final String dishId;
    final String dishName;
    final String dishDescription;
  
    CategoryDishes(
        {this.dishId,
        this.dishName,
        this.dishDescription,});
  
    factory CategoryDishes.fromJson(Map&lt;String, dynamic&gt; json) {
      return CategoryDishes(
          dishId: json['dish_id'],
          dishName: json['dish_name'],
          dishDescription: json['dish_description'],
  
    }
  
    static Resource&lt;List&lt;CategoryDishes&gt;&gt; get all {
      return Resource(
          url: Constants.FOOD_API_URL,
          parse: (response) {
            final result = json.decode(response.body.toString());
            print(response);
            Iterable list = result['category_dishes'];
            return list.map((model) =&gt; CategoryDishes.fromJson(model)).toList();
          });
    }
  }
  </code></pre>
  
  <p><strong>web_service.dart</strong></p>
  
  <pre><code>class Resource&lt;T&gt; {
    final String url;
    T Function(Response response) parse;
  
    Resource({this.url, this.parse});
  }
  
  class Webservice {
    Future&lt;T&gt; load&lt;T&gt;(Resource&lt;T&gt; resource) async {
      final response = await http.get(resource.url);
      if (response.statusCode == 200) {
        debugPrint("----D------&gt;" + response.body);
        return resource.parse(response);
      } else {
        throw Exception('Failed to load data!');
      }
    }
  }
  </code></pre>
  
  <p>The <code>debugPrint</code> showing the api in console, but also the above error showing and the api data not showing on my view that I've created.</p>
  
  <p>What I did wrong?</p>
  
  <p>Any suggestion would be helpful.</p>