postString method

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

Implementation

Future<String> postString(
  dynamic url, {
  Map<String, dynamic>? 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);
  }
  final response = await post(url, headers: headers, body: json.encode(body));
  if (_closed) throw HttpClientClosedException();

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

  return response.body;
}