[英]How do I make a post request of a json nested in flutter?
I will make the normal request in a simple JSON, but when it is written I will not make the request.我将在一个简单的 JSON 中发出正常请求,但是当它写出来时我不会发出请求。 If anyone can help me with the post request of this JSON and model.
如果有人可以帮助我处理此 JSON 和 model 的发布请求。
JSON: JSON:
{
"nit":12335667,
"name": "it",
"city": {
"id": 1,
"name": "New York",
"code": 132
}
}
If what you are looking for is to make a post, something like that would still work, but I would recommend this article .如果您正在寻找的是发帖,类似的东西仍然可以工作,但我会推荐这篇文章。
class MyPostRequest extends StatelessWidget {
final location = {
"nit": 12335667,
"name": "it",
"city": {"id": 1, "name": "New York", "code": 132}
};
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text('Make a Post Request'),
onPressed: () async {
var response = await http.post(
'https://www.example.com',
body: location,
);
},
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.