看,首先,GET
操作不是为了发送数据。它用于接收数据,因此方法名称为GET
,因此http.get()
没有body
.
如果发送的数据是最大的需求,那么你就需要使用Uri
到添加query parameter
到http
方法。
请阅读有关Uri.http flutter 的更多信息。
你可以做这样的事情来实现你想要的:
// Please note "...." for more information, please do not use this as is
// Just wanted to give a heads up
final query = {
'name': your_name,
'email': your_email,
'password': your_password
...
};
var url = 'linkofapi;
// Now you use the query to pass it to. your get method
final uri = Uri.http(url, '/path', query);
// adding headers to the query
final header = {HttpHeaders.contentTypeHeader: 'application/json'};
// doing the operation finally
final response = await http.get(uri, headers: header);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句