post method Null safety
- Uri url,
- {Map<
String, String> ? headers, - Object? body,
- Encoding? encoding}
Sends an HTTP POST request with the given headers and body to the given URL.
body
sets the body of the request. It can be aString
, aList
or aMap<String, String>
. If it's a String, it's encoded usingencoding
and used as the body of the request.- The content-type of the request will default to "text/plain".
- If
body
is a List, it's used as a list of bytes for the body of the request. - If
body
is a Map, it's encoded as form fields usingencoding
. The content-type of the request will be set to "application/x-www-form-urlencoded"; this cannot be overridden.encoding
defaults toutf8
.
Implementation
Future<http.Response> post(
Uri url, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) async {
return client.post(
url,
headers: headers,
body: body,
encoding: encoding,
);
}