post<T> function

Future<Response<T>> post<T>(
  1. String unencodedPath, {
  2. Protocol protocol = Protocol.https,
  3. String? service,
  4. Map<String, String>? headers,
  5. Map<String, dynamic>? parameters,
  6. Map<String, dynamic>? body,
  7. Duration timeout = const Duration(seconds: 10),
  8. ResponseDataBuilder<T>? to,
  9. PostClient? postClient,
})

Implementation

Future<Response<T>> post<T>(
  final String unencodedPath, {
  final Protocol protocol = Protocol.https,
  final String? service,
  final Map<String, String>? headers,
  final Map<String, dynamic>? parameters,
  final Map<String, dynamic>? body,
  final Duration timeout = const Duration(seconds: 10),
  final type.ResponseDataBuilder<T>? to,
  final type.PostClient? postClient,
}) async => _buildResponse<T>(
  checkStatus(
    await (postClient ?? http.post)
        .call(
          util
              .getUriFactory(protocol)
              .call(
                service ?? defaultService,
                unencodedPath,
                util.convertParameters(util.removeNullValues(parameters) ?? {}),
              ),
          headers: {'Content-type': 'application/json'}..addAll(headers ?? {}),
          body: body != null
              ? jsonEncode(util.removeNullValues(body) ?? {})
              : null,
          encoding: utf8,
        )
        .timeout(timeout),
  ),
  to,
);