title: Flutter newbie - Fetching data from a JSON file with http
body: <p>I'm new in this http and JSON world, so I may be wrong on stating or naming some terms. I'm getting a course from Udemy and I'm trying to get a specific object or that object's property. But whatever I do, I'm still fetching <strong>all the data</strong>, instead of <strong>an index</strong>.</p>
  <p>Here's my code:</p>
  <pre><code>import 'dart:convert';
  import 'package:flutter/material.dart';
  import 'package:http/http.dart';
  
  class JsonParsingSimple extends StatefulWidget {
  
    @override
    _JsonParsingSimpleState createState() =&gt; _JsonParsingSimpleState();
  }
  
  class _JsonParsingSimpleState extends State&lt;JsonParsingSimple&gt; {
    Future data;
  
    @override
    void initState() {
      // TODO: implement initState
      super.initState();
      data = getData();
    }
  </code></pre>
  <p>{...}</p>
  <pre><code>  Future getData() async
    {
      Future data;
      String url = &quot;https://jsonplaceholder.typicode.com/posts&quot;;
      Network network = Network(url);
  
      data = network.fetchData();
      data.then((value)
      {
        print(value[0]['title']); //this line still brings me every data like i'm writing *(value)*
      });
      
      return data; 
    }
  }
  
  class Network
  {
    final String url;
    Network(this.url);
  
    Future fetchData() async
    {
      print(&quot;$url&quot;);
      Response response = await get(Uri.parse(url));
  
      if(response.statusCode == 200)
      {
        print(response.body);
        return json.decode(response.body); 
      }
      else
      {
        print(response.statusCode);
      }
    }
    
  }
  </code></pre>
  <p><code>print(value)</code> or <code>print(value[0])</code> or <code>print(value[0]['id'])</code>. They're all giving the same. Fetching everything.</p>