title: returning a widget based on the json result from POST method in flutter
body: <p>my dashboard.dart look like this </p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'dart:async';
  import 'dart:convert';
  import 'package:abc/utils/connection_config.dart';
  import 'package:abc/screens/loginpage.dart';
  import 'package:http/http.dart' as http;
  import 'package:flutter/cupertino.dart';
  
  class Dash extends StatefulWidget {
    @override
    DashState createState() =&gt; DashState();
  }
  
  class DashState extends State&lt;Dash&gt; {
    Future reportList;
  
    @override
    void initState() {
      super.initState();
      reportList = getDashboardData();
    }
  
    getDashboardData() async {
      var fromtime = 1567449000000;
      var totime = 1567770486144;
      var mtype = "internet";
  
      http.Response response = await http.post(dashboardURL,
          headers: {"Content-type": "application/json"},
          body: json.encode({
            "fromTime": fromtime,
            "mtype": mtype,
            "must": [
              {"msg_status": "0"}
            ],
            "toTime": totime
          }));
      switch (response.statusCode) {
        case 200:
          String dashboardResult = response.body;
          var collection = json.decode(dashboardResult);
          return collection;
          break;
        case 403:
        case 401:
          return null;
        default:
          return 1;
      }
    }
  
    Widget getContents(BuildContext context, var data) { //here I want to return the widget for each entry in hits array
      Widget _widget;
      _widget = SingleChildScrollView(
        child: SingleChildScrollView(
          child: Container(
            child: ,
            ),
          ),
        );
      return _widget;
    }
  
  
  
  //function that iterates over the list
  
  
    getRefreshScaffold() {
      return Center(
        child: RaisedButton(
          onPressed: () {
            setState(() {
              reportList = getDashboardData();
            });
          },
          child: Text('Refresh, Network issues.'),
        ),
      );
    }
  
    @override
    Widget build(BuildContext context) {
      return FutureBuilder(
        future: reportList,
        builder: (BuildContext context, AsyncSnapshot snapshot) {
          switch (snapshot.connectionState) {
            case ConnectionState.none:
            case ConnectionState.waiting:
            case ConnectionState.active:
              return Center(
                child: CircularProgressIndicator(),
              );
            case ConnectionState.done:
              var data = snapshot.data;
              if (snapshot.hasData &amp;&amp; !snapshot.hasError) {
                return Container(
                  child: getContents(context, snapshot.data),
                );
              } else if (data == null) {
                return Center(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: &lt;Widget&gt;[
                      Text("Timeout! Log back in to continue"),
                      Padding(
                        padding: EdgeInsets.all(25.0),
                      ),
                      RaisedButton(
                        onPressed: () {
                          setState(() {
                            token = null;
                          });
                          Navigator.of(context).pushReplacement(
                            CupertinoPageRoute(
                                builder: (BuildContext context) =&gt; LoginPage()),
                          );
                        },
                        child: Text('Login Again!'),
                      ),
                    ],
                  ),
                );
              } else {
                getRefreshScaffold();
              }
          }
        },
      );
    }
  }
  </code></pre>
  
  <p>Here I am hitting an api that gives the json there i need to loop over the following ,</p>
  
  <pre><code>{
  ..... some other data
  
      "hitsArray": [
              {
                  "tt": 1567566438144,
                  "status": "0",
                  "count": 2257056,
                  "status_count": 2257053
              },
              {
                  "tt": 1567566438144,
                  "status": "1",
                  "count": 2257056,
                  "status_count": 3
              }
          ],
      ...some other data
      }
  </code></pre>
  
  <p>what iam trying to do is to loop over the hitsarray in the json result and to display each entry in a widget.
  but i am not getting how to loop over the json data and assign an widget to display it, I tried my best but not able to get it.</p>