title: Flutter Dropdown: type 'String' is not a subtype of type 'int' of 'index'
body: <p>I am trying to use a dropdown list in flutter and values of dropdown are supposed to add by HTTP request.</p>
  
  <p>Here is the code for HTTP.</p>
  
  <pre><code>Future&lt;String&gt; getData() async {
      try{ 
      var deviceid = '123';
        var dtgUid = '123';
  
        var body = { "uid" : dtgUid, "deviceid": deviceid};
  
         var response = await http.post(url, body: json.encode(body)).timeout(Duration(seconds: 15),
              onTimeout: (){
                      //  throw Exception();
                _showSnackBar(context,'Some issue with connectivity. Can not connect to server.',Colors.redAccent);
                        //or you can also
                return null;
              });
  
       if(response. statusCode == 200){
          final datafromdb = getNewsTypeFromJson(response.body);
          setState(() {
            _inProcess = false;
                          if(datafromdb.content.length == null){
                            count = 0;
                          }else{
                            count = datafromdb.content.length;
                          }
  
                           if(datafromdb.content.length &gt; 0 &amp;&amp; datafromdb.content[0].tagname != 'Empty'){
                          for (var i in datafromdb.content) {
                            print(i.tagname);
                            data.add(i.tagname);
                          }  
                        }else{
                          nodata = 'No Record Found';
                          _showSnackBar(context,nodata,Colors.redAccent);
                        }
  
          });
       }
         }catch(e){
         print("Exception Caught: $e");
      }
  
  
      }
  </code></pre>
  
  <p>Here is the JSONParse.</p>
  
  <pre><code>import 'dart:convert';
  
  GetNewsType getNewsTypeFromJson(String str) =&gt; GetNewsType.fromJson(json.decode(str));
  
  class GetNewsType {
      GetNewsType({
          this.content,
          this.success,
      });
  
      List&lt;Content&gt; content;
      bool success;
  
      factory GetNewsType.fromJson(Map&lt;String, dynamic&gt; json) =&gt; GetNewsType(
          content: List&lt;Content&gt;.from(json["content"].map((x) =&gt; Content.fromJson(x))),
          success: json["success"],
      );
  
  }
  
  class Content {
      Content({
          this.tagname,
      });
  
      String tagname;
  
      factory Content.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Content(
         // tagname: json["tagname"],
          tagname: json == null ? 'Empty' : json["tagname"]
      );
  }
  </code></pre>
  
  <p>Here is the code for dropdown.</p>
  
  <pre><code>DropdownButton(
                          items: data.map((item) {
                            return DropdownMenuItem(
                              child: Text(item['tagname']),
                              value: item['tagname'].toString(),
                            );
                          }).toList(),
                          onChanged: (newVal) {
                            setState(() {
                              _mySelection = newVal;
                            });
                          },
                          value: _mySelection,
                        ),
  </code></pre>
  
  <p>When I run the app it is giving below error. Which I don't understand.</p>
  
  <pre><code>type 'String' is not a subtype of type 'int' of 'index'
  </code></pre>