[英]How to send Post request with String params with flutter
大家好,我需要用flutter将一些字符串参数发送到服务器,但是http包将json作为参数发送到服务器而不是字符串。
perhaps set the body
parameter to a Map
in the http.post
call? 也许在http.post
调用中将body
参数设置为Map
?
import 'package:http/http.dart' as http;
var url = 'http://example.com/post';
var response = await http.post(url, body: {'name': 'doodle', 'color': 'blue'});
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.