downloadFile method

Future<Uint8List> downloadFile({
  1. required String urlName,
  2. Map<String, dynamic>? data,
})

Downloads a file from urlName and returns its raw bytes.

Implementation

Future<Uint8List> downloadFile(
    {required String urlName, Map<String, dynamic>? data}) async {
  final url = Uri.parse(urls.getUrl(urlName));
  ensureHeaders({'Content-Type': 'application/json', 'responseType': 'blob'});

  final request = await http.post(
    url,
    body: jsonEncode(data),
    headers: _headers,
  );
  return request.bodyBytes;
}