postString method

Future<String> postString(
  1. dynamic url, {
  2. Map<String, String>? body,
  3. Map<String, String> headers = const {},
  4. bool validate = true,
})

Implementation

Future<String> postString(dynamic url,
    {Map<String, String>? body,
    Map<String, String> headers = const {},
    bool validate = true}) async {
  assert(url is String || url is Uri);
  if (url is String) {
    url = Uri.parse(url);
  }
  var response = await post(url, headers: headers, body: body);
  if (_closed) throw HttpClientClosedException();

  if (validate) {
    _validateResponse(response, response.statusCode);
  }

  return response.body;
}