title: How to cancel ongoing file upload sent with http.MultipartRequest() in Flutter?
body: <p>I'm trying to add cancel functionality to file upload in my Flutter app. I'm currently using <code>http.MultipartRequest()</code> from <code>http package</code> to upload the file. I've tried wrapping the upload with <code>CancelableOperation</code> but it only cancels the internal process within my Flutter app and the file still gets uploaded successfully to my Firebase Storage server.</p>
  
  <p>I read the README.md on http package about using <code>http.Client()</code> and closing it after the http request is completed. I'm thinking about using <code>http.Client()</code> to upload the file and then closing it with the <code>http.Client().close()</code> to cancel the http request.</p>
  
  <p>But, I haven't found the right way to upload file with <code>http.Client</code> yet. I browsed about it on Google and stackoverflow but all the posts recommend using <code>http.MultipartRequest()</code>. <a href="https://stackoverflow.com/questions/22600488/how-can-i-upload-a-pdf-using-darts-httpclient">One of the posts</a></p>
  
  <p>So, my questions are: 
  1. Is it possible to cancel upload file sent with <code>http.MultipartRequest()</code> from http package in Flutter? 
  2. Am I in the right track with trying to use <code>http.Client()</code> ? Or is there any better way to do this?
  3. If using <code>http.Client()</code> is the only way, then can you please show me how to upload file with <code>http.Client()</code>? since it only has <code>post()</code> and no <code>multipartrequest()</code>.</p>
  
  <p>Sorry for the long text. Please help. Thanks!</p>