title: flutter - Error: A value of type 'Articles' can't be assigned to a variable of type 'int'
body: <p>I am trying to create a medium clone using <a href="https://conduit.productionready.io" rel="nofollow noreferrer">https://conduit.productionready.io</a> and when I am calling API <a href="https://conduit.productionready.io/api/articles" rel="nofollow noreferrer">https://conduit.productionready.io/api/articles</a> I am storing data in Article model and then printing using the map.toList() method but</p>
  <p>I am getting an error: flutter -  Error: A value of type 'Articles' can't be assigned to a variable of type 'int'.</p>
  <pre><code>lib/screens/myhome_screen.dart:47:49: Error: A value of type 'Articles' can't be assigned to a variable of type 'int'.
   - 'Articles' is from 'package:conduit/models/globally_articles.dart' ('lib/models/globally_articles.dart').
                  Text(&quot;${globalArticles.articles[index].title}&quot;),
  </code></pre>
  <p>my_homescreen.dart</p>
  <pre class="lang-dart prettyprint-override"><code> import 'dart:convert';
  
  import 'package:conduit/models/globally_articles.dart';
  import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
  import 'package:http/http.dart' as http;
  
  class GlobalFeed extends StatefulWidget {
    @override
    _GlobalFeedState createState() =&gt; _GlobalFeedState();
  }
  
  class _GlobalFeedState extends State&lt;GlobalFeed&gt; {
    bool isLoading = true;
  
    GlobalArticles globalArticles;
  
    @override
    void initState() {
      // TODO: implement initState
      super.initState();
      getGlobalArticles();
      setState(() {
        isLoading = false;
      });
    }
  
    getGlobalArticles() async {
      var url = 'https://conduit.productionready.io/api/articles';
      var response = await http.get(url);
  
      setState(() {
        var jsonData = jsonDecode(response.body);
        globalArticles = GlobalArticles.fromJson(jsonData);
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: SingleChildScrollView(
          child: Column(
              children: globalArticles.articles.map((index) {
                return Card(
                  child: Column(
                    children: [
                      Text(&quot;${globalArticles.articles[index].title}&quot;),
                    ],
                  ),
                );
              }).toList()),
        ),
      );
    }
  }
  
  </code></pre>
  <p>globalArticles.dart</p>
  <pre><code>class GlobalArticles {
    List&lt;Articles&gt; articles;
    int articlesCount;
  
    GlobalArticles({this.articles, this.articlesCount});
  
    GlobalArticles.fromJson(Map&lt;String, dynamic&gt; json) {
      if (json['articles'] != null) {
        articles = new List&lt;Articles&gt;();
        json['articles'].forEach((v) {
          articles.add(new Articles.fromJson(v));
        });
      }
      articlesCount = json['articlesCount'];
    }
  
    Map&lt;String, dynamic&gt; toJson() {
      final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;();
      if (this.articles != null) {
        data['articles'] = this.articles.map((v) =&gt; v.toJson()).toList();
      }
      data['articlesCount'] = this.articlesCount;
      return data;
    }
  }
  
  class Articles {
    String title;
    String slug;
    String body;
    String createdAt;
    String updatedAt;
    List&lt;String&gt; tagList;
    String description;
    Author author;
    bool favorited;
    int favoritesCount;
  
    Articles(
        {this.title,
          this.slug,
          this.body,
          this.createdAt,
          this.updatedAt,
          this.tagList,
          this.description,
          this.author,
          this.favorited,
          this.favoritesCount});
  
    Articles.fromJson(Map&lt;String, dynamic&gt; json) {
      title = json['title'];
      slug = json['slug'];
      body = json['body'];
      createdAt = json['createdAt'];
      updatedAt = json['updatedAt'];
      tagList = json['tagList'].cast&lt;String&gt;();
      description = json['description'];
      author =
      json['author'] != null ? new Author.fromJson(json['author']) : null;
      favorited = json['favorited'];
      favoritesCount = json['favoritesCount'];
    }
  
    Map&lt;String, dynamic&gt; toJson() {
      final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;();
      data['title'] = this.title;
      data['slug'] = this.slug;
      data['body'] = this.body;
      data['createdAt'] = this.createdAt;
      data['updatedAt'] = this.updatedAt;
      data['tagList'] = this.tagList;
      data['description'] = this.description;
      if (this.author != null) {
        data['author'] = this.author.toJson();
      }
      data['favorited'] = this.favorited;
      data['favoritesCount'] = this.favoritesCount;
      return data;
    }
  }
  
  class Author {
    String username;
    String bio;
    String image;
    bool following;
  
    Author({this.username, this.bio, this.image, this.following});
  
    Author.fromJson(Map&lt;String, dynamic&gt; json) {
      username = json['username'];
      bio = json['bio'];
      image = json['image'];
      following = json['following'];
    }
  
    Map&lt;String, dynamic&gt; toJson() {
      final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;();
      data['username'] = this.username;
      data['bio'] = this.bio;
      data['image'] = this.image;
      data['following'] = this.following;
      return data;
    }
  }
  </code></pre>