title: How to make lazy loading with FutureBuilder in flutter
body: <p>I searched in a lot of topics but couldn't find solution to my problem. I try to make lazy loading with FutureBuilder to listview. All topics I found the code different from what I have. I don't want to apply it from a package. Sorry about that but I'm still not a professional in flutter. Can someone help me.</p>
  <p>thank you</p>
  <p>My code:</p>
  <pre><code>class _HomePageState extends State&lt;YourPost&gt; {
  
  
  
  
    @override
    void initState() {
      super.initState();
    }
  
  
    Future ApiUserPost() async {
  
      final String url = '*************';
      var response = await http.post(Uri.parse(url));
      var responsebody = jsonDecode(response.body);
  
      if (responsebody.length &gt; 0) {
        return responsebody;
      } else {
  
      }
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
          body: Center(
        child: Container(
          child: SingleChildScrollView(
            child: Column(
              children: &lt;Widget&gt;[
                FutureBuilder(
                    future: ApiUserPost(),
                    builder: (context, AsyncSnapshot snapshot) {
                      if (snapshot.hasData) {
                        return ListView.builder(
                            physics: ScrollPhysics(),
                            scrollDirection: Axis.vertical,
                            shrinkWrap: true,
                            itemCount: snapshot.data.length.clamp(0, 6),
                            itemBuilder: (context, index) {
                              return Card(
                                // elevation: 1,
                                child: Container(
                                  padding: EdgeInsets.all(6),
                                  child: Row(
                                    children: &lt;Widget&gt;[
                                      Flexible(
                                        child: Column(
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                          children: &lt;Widget&gt;[
                                            MergeSemantics(
                                              child: Row(
                                                children: &lt;Widget&gt;[
                                                  Flexible(
                                                    child: Text(
                                                      &quot;${snapshot.data[index]['name']}&quot;,
                                                    ),
                                                  )
                                                ],
                                              ),
                                            ),
                                            SizedBox(height: 5),
                                          ],
                                        ),
                                      )
                                    ],
                                  ),
                                ),
                              );
                            });
                      } else if (snapshot.hasError) {
                        Center(
                            child: CircularProgressIndicator(
                              valueColor:
                              new AlwaysStoppedAnimation&lt;Color&gt;(Colors.black),
                            ),);
                      }
  
                      return SizedBox(
                        height: MediaQuery.of(context).size.height / 1.3,
                        child: Center(
                          child: CircularProgressIndicator(
                            valueColor:
                                new AlwaysStoppedAnimation&lt;Color&gt;(Colors.black),
                          ),
                        ),
                      );
                    })
              ],
            ),
          ),
        ),
      ));
    }
  }
  
  
  </code></pre>