How to fetch a list of maps to a calendar? [Flutter]

后端 未结 2 1456
陌清茗
陌清茗 2021-01-23 06:40

I have a json object here -

{
    \"error\": \"0\",
    \"message\": \"Got it!\",
    \"data\": [
        {
            \"status\": false,
            \"_id\":          


        
2条回答
  •  温柔的废话
    2021-01-23 07:34

    I think your fetch method should be like this:

      Future> getData() async{
      String link = baseURL + fetchTodoByDate;
      var res = await http.post(Uri.encodeFull(link), headers: {"Accept": "application/json"});
    
    var fetch =  List();
    if (res.statusCode == 200 ) {
      var datesJson = json.decode(res.body);
      for(var dateJson in datesJson){
        fetch.add(Data.fromJson((dateJson)));
      }
    }
    return fetch;
    

    }

提交回复
热议问题