put<T> static method

dynamic put<T>(
  1. String path, {
  2. dynamic data,
  3. Map<String, Object>? queryParameters,
  4. Map<String, Object>? propertiesToLog,
  5. Options? options,
  6. CancelToken? cancelToken,
  7. ProgressCallback? onSendProgress,
  8. ProgressCallback? onReceiveProgress,
  9. bool trackTelemetry = true,
  10. TelemetryClient? telemetryClient,
})

Implementation

static put<T>(String path,
    {data,
      Map<String, Object>? queryParameters,
      Map<String, Object>? propertiesToLog,
      Options? options,
      CancelToken? cancelToken,
      ProgressCallback? onSendProgress,
      ProgressCallback? onReceiveProgress,
      bool trackTelemetry = true,
      TelemetryClient? telemetryClient,
    }) async {
  final stopwatch = Stopwatch()..start();
  final timestamp = DateTime.now().toUtc();

  // TODO
  // final contentLength = data.map((x) => x.value.length).reduce((a,b) => a + b);

  try {
    var response = await _dio.put(path,
        data: data,
        queryParameters: queryParameters,
        options: options,
        cancelToken: cancelToken,
        onSendProgress: onSendProgress,
        onReceiveProgress: onReceiveProgress);

    if (trackTelemetry) {
      _sendTelemetry(response, null, "PUT", timestamp, path, queryParameters, propertiesToLog, stopwatch, telemetryClient);
    }
    return response;
  } on DioError catch (error) {
    _sendErrorTelemetry(error, 0, "PUT", timestamp, path, queryParameters, propertiesToLog, stopwatch, telemetryClient);
    throw Future.error(error);
  }
}