postCallback<T> static method

dynamic postCallback<T>(
  1. String path, {
  2. bool showLoading = false,
  3. DioMethod method = DioMethod.post,
  4. Map<String, dynamic>? params,
  5. CancelToken? cancelToken,
  6. Options? options,
  7. required void success(
    1. Response
    )?,
  8. void error(
    1. DioException
    )?,
  9. Function? complete,
})

http POST request return Void params required callback function

Implementation

static postCallback<T>(String path,
    {bool showLoading = false,
    DioMethod method = DioMethod.post,
    Map<String, dynamic>? params,
    CancelToken? cancelToken,
    Options? options,
    required void Function(Response)? success,
    void Function(DioException)? error,
    Function? complete}) {
  HttpUtils()
      .request(path, showLoading: showLoading, method: method, data: params, options: options, cancelToken: cancelToken)
      .then((value) {
    if (success != null) {
      success(value);
    }
  }).catchError((Object err) {
    if (error != null) {
      error(err as DioException);
    }
  }).whenComplete(() {
    if (complete != null) {
      complete();
    }
  });
}