flutter post删除方法

  Map get headers => {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": "dfgfdgsfd",
      };
      void _showSnackBar(String acid,int index) async {
      Map data = {
       'id': acid,
    };

     String body = json.encode(data);
     var response = await http.post(
      'https://www.51dev.com/api/v1/del_ist',
      body:body,
      headers: headers,
    );
     print(response.body);
     print("index $index");
    if(response.statusCode==200){
       setState(() {
         _getNews();
         hotList.removeAt(index); 
       });
         Toast.show("删除成功",
                              context,
                              duration: Toast.LENGTH_SHORT,
                              gravity: Toast.CENTER,
                              backgroundRadius: 26.0);
    }

  }

 

你可能感兴趣的