put static method

Future<CommonResponse> put(
  1. String partUrl,
  2. dynamic body,
  3. void successCompletion(
    1. CommonResponse
    ),
  4. void errCompletion(
    1. CommonResponse
    ),
  5. bool isMultipart,
  6. String? token,
)

Implementation

static Future<CommonResponse> put(
    String partUrl,
    dynamic body,
    void Function(CommonResponse) successCompletion,
    void Function(CommonResponse) errCompletion,
    bool isMultipart,
    String? token) async {
  late CommonResponse commonResponse;
  Dio dio = initDio(partUrl, false);
  await dio
      .put("",
          options: token != null
              ? Options(
                  contentType: Headers.jsonContentType,
                  headers: {"Authorization": "Token $token"})
              : Options(contentType: Headers.jsonContentType),
          data: body)
      .then((response) {
    debugPrint("res ==== " + response.toString());
    commonResponse = CommonResponse.fromJson(response.data);

    if (commonResponse.success!) {
      successCompletion(commonResponse);
    } else {
      errCompletion(commonResponse);
    }
  }).catchError((e) {
    if (e is DioError) {
      commonResponse = CommonResponse.fromJson(e.response?.data);
      debugPrint("err ==== ${e.response}");
      errCompletion(commonResponse);
    }
  });
  return commonResponse;
}