post method

Future<Map<String, Object?>> post(
  1. String path,
  2. Map<String, Object?> body
)

POST com corpo JSON. Retorna o data (ex.: {id: N}).

Implementation

Future<Map<String, Object?>> post(
  String path,
  Map<String, Object?> body,
) async {
  final res = await http.post(
    Uri.parse('$baseUrl$path'),
    headers: const {'content-type': 'application/json'},
    body: jsonEncode(body),
  );
  final data = _unwrap(res.body, res.statusCode);
  return data is Map ? data.cast<String, Object?>() : const {};
}