put method

Future<Response> put(
  1. String path, {
  2. required Map<String, dynamic> data,
  3. APIType apiType = APIType.public,
  4. TokenType tokenType = TokenType.bearer,
  5. bool isFormData = false,
  6. Map<String, dynamic>? headers,
  7. Map<String, dynamic>? query,
})

Implementation

Future<Response<dynamic>> put(
  String path, {
  required Map<String, dynamic> data,
  APIType apiType = APIType.public,
  TokenType tokenType = TokenType.bearer,
  bool isFormData = false,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? query,
}) async {
  _setDioInterceptorList();

  final standardHeaders = await _getOptions(apiType, tokenType);

  if (isFormData) {
    if (headers != null) {
      standardHeaders.headers?.addAll({
        'Content-Type': 'multipart/form-data',
      });
    }
    data.addAll({
      '_method': 'PUT',
    });
  } else {
    if (headers != null) {
      standardHeaders.headers?.addAll(headers);
    }
  }

  return _dio
      .put(
        path,
        data: isFormData ? FormData.fromMap(data) : data,
        options: standardHeaders,
      )
      .then((value) => value)
      .catchError(_handleException);
}