contentType property

String? contentType
inherited

Implementation

String? get contentType => _headers[Headers.contentTypeHeader] as String?;
void contentType=(String? contentType)
inherited

The request Content-Type. The default value is ContentType.json. If you want to encode request body with 'application/x-www-form-urlencoded', you can set ContentType.parse('application/x-www-form-urlencoded'), and Dio will automatically encode the request body.

Implementation

set contentType(String? contentType) {
  if (contentType != null) {
    _headers[Headers.contentTypeHeader] =
        _defaultContentType = contentType.trim();
  } else {
    _defaultContentType = null;
    _headers.remove(Headers.contentTypeHeader);
  }
}