post method
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 a String, a List<int>
or a Map<String, String>.
If body
is a String, it's encoded using encoding
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 using encoding
. The
content-type of the request will be set to
"application/x-www-form-urlencoded"
; this cannot be overridden.
encoding
defaults to utf8.
For more fine-grained control over the request, use send instead.
Implementation
@override
Future<Response> post(
final url, {
Map<String, String>? headers,
final body,
final Encoding? encoding,
}) async {
headers = _initHeader(headers);
// debugPrint('... ==> POST ${Uri.parse('$_baseUrl$url')}');
// debugPrint('... ==> headers $headers');
// debugPrint('... ==> body $body');
final response = await super.post(
Uri.parse('$_baseUrl$url'),
headers: headers,
body: body,
encoding: encoding,
);
return _checkResponse(response);
}