postTo method

Future postTo(
  1. dynamic url,
  2. dynamic headers,
  3. Map body
)

Implementation

Future postTo(
  var url,
  var headers,
  Map body,
) async {
  String bodyString = json.encode(body);
  http.Response response =
      await http.post(url, headers: headers, body: bodyString);
  if (response.statusCode != 200) {
    var json = jsonDecode(response.body);
    print('rest.dart: postTo: $url: Non 200 response recevied: $json');
    return;
  }
  // print('rest.dart: postTo: $url successful: response: $response');
  String responseBody = response.body;
  return json.decode(responseBody);
}