post<T> method

Future<SmartApiResponse<T>> post<T>(
  1. String endpoint, {
  2. dynamic body,
  3. List<SmartApiFile>? files,
  4. Map<String, dynamic>? queryParams,
  5. bool? autoDetectFiles,
  6. bool forceRaw = false,
  7. T fromJson(
    1. dynamic
    )?,
  8. bool showLoader = true,
})

Sends a POST request to endpoint. If body contains a File or local file path (and autoDetectFiles isn't disabled), or files is provided, the request is sent as multipart form data — otherwise it's sent as raw JSON.

Pass forceRaw: true to send body exactly as given (skipping file detection and JSON-map handling entirely) — useful for endpoints that expect a raw string/XML/pre-encoded payload instead of a JSON map.

Implementation

Future<SmartApiResponse<T>> post<T>(String endpoint,
        {dynamic body,
        List<SmartApiFile>? files,
        Map<String, dynamic>? queryParams,
        bool? autoDetectFiles,
        bool forceRaw = false,
        T Function(dynamic)? fromJson,
        bool showLoader = true}) =>
    call<T>(
        SmartApiRequest(
          endpoint: endpoint,
          method: ApiMethod.post,
          body: body,
          files: files,
          queryParams: queryParams,
          autoDetectFiles: autoDetectFiles,
          forceRaw: forceRaw,
          showLoader: showLoader,
        ),
        fromJson: fromJson);