title: How to fetch json data and separate it based on a Parameter?
body: <p>I have a json object here - </p>
  
  <pre><code>{
      "error": "0",
      "message": "Got it!",
      "data": [
          {
              "status": false,
              "_id": "5e2fbb74d465702288c54038",
              "group_id": "5e0d9e993944e46ed9a86d95",
              "date": "2020-01-28T00:00:00.000Z",
              "title": "cciigcigc",
              "priority": 3,
              "description": "",
              "tasks": [],
              "created_date": "2020-01-28T04:41:24.576Z",
              "__v": 0
          }
      ]
  }
  </code></pre>
  
  <p>I want to fetch it based on the ["data"]["status"] parameter; if the status is false, return a seperate list and if the status is true, return another list. I have tried to modify my current fetch method this way - </p>
  
  <pre><code>Future&lt;List&lt;Post&gt;&gt; gettask(bool identifier) async { // the identifier can be set to true and false 
    List&lt;Post&gt; statusComplete;
    List&lt;Post&gt; statusInComplete;
  
    String link = baseURL + fetchTodoByDate;
  //  print("printing from get task = $setter");
    Stopwatch stopwatchbefore = new Stopwatch()..start();
  
  
    var res = await http.post(Uri.encodeFull(link), headers: {"Accept": "application/json", }, body: {"date" : setter.toString()});
  
    print('fetch executed in ${stopwatchbefore.elapsed}');
  
  
    if (res.statusCode == 200) {
      Stopwatch stopwatchafter = new Stopwatch()
        ..start();
  
      var data = json.decode(res.body);
      var rest = data["data"] as List;
      if(identifier == true){
        statusComplete = rest.map&lt;Post&gt;((json) {
          // need help in implementing logic here
  
          return Post.fromJson(json);
        }).toList();
  
        return statusComplete;
  
      }else if(identifier == false){
        statusInComplete = rest.map&lt;Post&gt;((json) {
          // need help in implementing logic here
  
          return Post.fromJson(json);
        }).toList();
        return statusInComplete;
      }
  
      print('statuscode executed in ${stopwatchafter.elapsed}');
      Future.delayed(Duration(seconds: 5));
    }
  
  
  //  print("List Size: ${list.length}");
  }
  </code></pre>
  
  <p>This is the first time I am trying to fetch and separate the data this way. I have tried to look at some tutorials but none seemed to be satisfying my case. </p>
  
  <p>Could i get some suggestion on how to fetch the data and then separate it based on a parameter?</p>