title: Flutter: Loading json data within second page Flutter Class timing out without error
body: <p>I've generated a listView from the Pokemon API of a list of Pokemon, I then have onTap events to trigger a new page/class, where I'm passing the name and URL from the API to the new secondPage Class/Screen.</p>
  
  <p>I need to make a second request in this new page because the API Url needs to change to grab specific details but my request seems to be timing out..</p>
  
  <p>Here is my code: If loaded into a new project the first screen should function fine, loading a bunch of Pokemon and their API specific URLs into a listView.</p>
  
  <p>I can successfully pass the name and URL onto the second screen because they do appear in the Appbar.</p>
  
  <p>However when loading the new json data it seems to be timing out without any error.</p>
  
  <p>Does anyone have any advice for a newbie trying to get his footing?</p>
  
  <pre><code>import 'dart:async';
  import 'dart:convert';
  import 'package:basic_utils/basic_utils.dart';
  import 'package:flutter/material.dart';
  import 'package:http/http.dart' as http;
  
  void main() =&gt; runApp(new MyApp());
  
  class MyApp extends StatelessWidget {
    // This widget is the root of your application.
    @override
    Widget build(BuildContext context) {
      return new MaterialApp(
        home: new MyHomePage(),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    @override
    _MyHomePageState createState() =&gt; new _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    TextEditingController editingController = TextEditingController();
    String url = 'https://pokeapi.co/api/v2/pokemon/?limit=151';
    List data;
  
    Future&lt;String&gt; makeRequest() async {
      var response = await http
          .get(Uri.encodeFull(url), headers: {"Accept": "application/json"});
  
      setState(() {
        var extractData = json.decode(response.body);
        data = extractData["results"];
      });
    }
  
    @override
    void initState() {
      this.makeRequest();
    }
  
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
        appBar: new AppBar(
          title: new Text('Pokemon List'),
        ),
        body: Container(
          child: Column(
            children: &lt;Widget&gt;[
              Padding(
                padding: const EdgeInsets.all(15.0),
                child: new TextField(
                  onChanged: (value) {
                  },
                  decoration: InputDecoration(
                    labelText: "Search",
                    hintText: "Search",
                    contentPadding: const EdgeInsets.all(10.0),
                    prefixIcon: Icon(Icons.search),
                    border: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(6.0))
                    ),
                  ),
                ),
              ),
              Expanded(
                child: new ListView.builder(
                    itemCount: data == null ? 0 : data.length,
                    itemBuilder: (BuildContext context, i) {
                      return new ListTile(
                        title: new Text(StringUtils.capitalize(data[i]["name"])),
                        subtitle: new Text(data[i]["url"]),
                        //  leading: new CircleAvatar(
                        // backgroundImage:
                        // new NetworkImage(data[i]["picture"]["thumbnail"]),
                        //  ),
                        onTap: () {
                          Navigator.push(
                              context,
                              new MaterialPageRoute(
                                  builder: (BuildContext context) =&gt;
                                  new SecondPage(data[i])
                              )
                          );
                        },
                      );
                    }
                ),
              ),
            ],
          ),
        ),
      );
    }
  }
  
  // Class for getting Specific Details on SecondPage
  class Post {
    final String name;
    final int weight;
  
    Post({this.name, this.weight});
  
    factory Post.fromJson(Map&lt;String, dynamic&gt; json) {
      return Post(
        name: json['name'],
        weight: json['weight'],
      );
    }
  }
  // New Request for Specific Details
  class SecondPage extends StatelessWidget {
    SecondPage(this.data);
    final data;
  
    Future&lt;Post&gt; fetchPost() async {
      final response =
      await http.get('https://pokeapi.co/api/v2/pokemon/' + data["name"]);
      if (response.statusCode == 200) {
        // If the call to the server was successful, parse the JSON.
        return Post.fromJson(json.decode(response.body));
      } else {
        // If that call was not successful, throw an error.
        throw Exception('Failed to load post');
      }
    }
  
    Future&lt;Post&gt; post;
  
    @override
    void initState() {
      fetchPost();
      post = fetchPost();
    }
  
    @override
    Widget build(BuildContext context) =&gt;
        new Scaffold(
            appBar: new AppBar(
                title: new Text(data["name"] + ' - ' + data["url"])),
            body: new Center(
              child: Column(
                children: &lt;Widget&gt;[
                  Container(
                    padding: const EdgeInsets.all(30.0),
                    child: FutureBuilder&lt;Post&gt;(
                      future: post,
                      builder: (context, snapshot) {
                        if (snapshot.hasData) {
                           Text(snapshot.data.name);
                        } else if (snapshot.hasError) {
                          return Text("${snapshot.error}");
                        }
                        // By default, show a loading spinner.
                        return CircularProgressIndicator();
                      },
                    ),
                  ),
                ],
              ),
            )
        );
    }
  </code></pre>