title: flutter ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
body: <p>Model:</p>
  <pre class="lang-dart prettyprint-override"><code>class ModelClass {
    String? userId;
    String? id;
    String? title;
    String? body;
    ModelClass({
      this.userId,
      this.id,
      this.title,
      this.body,
    });
  
    Map&lt;String, dynamic&gt; toJson() {
      return {'userId': userId, 'id': id, 'title': title, 'body': body};
    }
  
    factory ModelClass.fromJson(Map&lt;String, dynamic&gt; data) {
      final userId = data['userId'];
      final id = data['id'];
      final title = data['title'];
      final body = data['body'];
      return ModelClass(id: id, userId: userId, title: title, body: body);
    }
  }
  </code></pre>
  <p>Repo:</p>
  <pre class="lang-dart prettyprint-override"><code>class GetPostProvider with ChangeNotifier {
    bool isLoading = false;
  
    List&lt;ModelClass&gt; modelclass = [];
  
    getMyData() async {
      isLoading = true;
      modelclass = await getAllPost();
      isLoading = false;
      notifyListeners();
    }
  
    Future&lt;List&lt;ModelClass&gt;&gt; getAllPost() async {
      final response =
          await http.get(Uri.parse('https://jsonplaceholder.typicode.com/posts'));
      List&lt;ModelClass&gt; mylist = [];
  
      try {
        if (response.statusCode == 200) {
          final jsonDecode = await json.decode(response.body);
          for (var i in jsonDecode['data']) {
            ModelClass _model = ModelClass.fromJson(i);
            mylist.add(_model);
          }
          return mylist;
        } else {
          return mylist;
        }
      } catch (e) {
        throw e.toString();
      }
    }
  }
  </code></pre>
  <p>UI:</p>
  <pre class="lang-dart prettyprint-override"><code>class HomePage extends StatefulWidget {
    const HomePage({Key? key}) : super(key: key);
  
    @override
    State&lt;HomePage&gt; createState() =&gt; _HomePageState();
  }
  
  class _HomePageState extends State&lt;HomePage&gt; {
    @override
    void initState() {
      // TODO: implement initState
      final provider = Provider.of&lt;GetPostProvider&gt;(context, listen: false);
      provider.getMyData();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      final provider = Provider.of&lt;GetPostProvider&gt;(context);
  
      return Scaffold(
          appBar: AppBar(
            title: const Text('User Id'),
          ),
          body: ListView.builder(
              itemCount: provider.modelclass.length,
              itemBuilder: ((context, index) {
                return ListTile(
                  title: Text(&quot;${provider.modelclass[index].body}&quot;),
                );
              })));
    }
  }
  </code></pre>
  <p>Error:</p>
  <pre class="lang-none prettyprint-override"><code>[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
  E/flutter (13226): #0      GetPostProvider.getAllPost (package:apiflutter/provider/postProvider.dart:51:7)
  E/flutter (13226): &lt;asynchronous suspension&gt;
  E/flutter (13226): #1      GetPostProvider.getMyData (package:apiflutter/provider/postProvider.dart:26:18)
  E/flutter (13226): &lt;asynchronous suspension&gt;
  E/flutter (13226):
  </code></pre>
  <p>Please help me</p>