uploadFile static method

dynamic uploadFile(
  1. dynamic context,
  2. dynamic businessId,
  3. File image
)

Implementation

static uploadFile(context, businessId, File image) async {
  Map<String, String> headers = {
    "Accept": "application/json",
    "x-api-id": "$businessId",
  };
  print(_uploadUrl);
  var uri = Uri.parse(_uploadUrl);

  var request = http.MultipartRequest("POST", uri);

  request.files.add(await http.MultipartFile.fromPath('file', image.path));

  request.fields['fileType'] = 'image';
  request.headers.addAll(headers);

  var response = await request.send();

  return response;
}