call method

Future call(
  1. String data,
  2. BuildContext? context,
  3. String url,
  4. String token, {
  5. Function? noNetworkCallBack,
  6. dynamic sessionExpiredCallback(
    1. BuildContext
    )?,
  7. String? clientId,
  8. String? clientSecret,
})

Implementation

Future<dynamic> call(
    String data, BuildContext? context, String url, String token,
    {Function? noNetworkCallBack,
    Function(BuildContext)? sessionExpiredCallback,String? clientId,String? clientSecret}) async {
  log(token, name: "Header Token");
  log(url, name: "Api Url");
  var headers = {
    "Content-Type": 'application/json',
    "Authorization": token,
  };

  if(clientId!=null && clientSecret!=null){
    headers.putIfAbsent("X-Client-Id",()=>clientId);
    headers.putIfAbsent("X-Client-Secret",()=>clientSecret);
  }
  log(headers.toString(), name: "Headers");
  return _netUtil
      .post(context, url,
          body: data,
          headers: headers,
          noNetworkCallBack: noNetworkCallBack,
          sessionExpiredCallback: sessionExpiredCallback)
      .then((dynamic res) {
    return _decoder.convert(res.toString());
  }).catchError((onError) {
    log(onError.toString());
  });
}