postAsync method

Future postAsync(
  1. String endPoint,
  2. Map data
)

Implementation

Future<dynamic> postAsync(String endPoint, Map data) async {
  String url = this._getOAuthURL("POST", endPoint);

  http.Client client = http.Client();
  http.Request request = http.Request('POST', Uri.parse(url));
  request.headers[HttpHeaders.contentTypeHeader] =
      'application/json; charset=utf-8';
  request.headers[HttpHeaders.cacheControlHeader] = "no-cache";
  request.body = json.encode(data);
  String response =
      await client.send(request).then((res) => res.stream.bytesToString());
  var dataResponse = await json.decode(response);
  return dataResponse;
}