post method

Future<Response> post(
  1. String ip,
  2. String path, {
  3. Map<String, String>? headers,
  4. Map<String, dynamic>? body,
})
inherited

Implementation

Future<http.Response> post(
  String ip,
  String path, {
  Map<String, String>? headers,
  Map<String, dynamic>? body,
}) async {
  final myIp = await client.getCurrentIp();
  if (myIp == null) {
    throw StateError('missing client IP');
  }

  final binding = await DeviceRequestBindingModel.create(
    clientIp: myIp,
    serverIp: ip,
    method: 'POST',
    path: path,
  );
  return client.post(
    ip,
    path,
    headers: {
      'Content-Type': 'application/json',
      ...?headers,
      ...binding.toHeaders(),
    },
    body: body,
  );
}