title: How to upload images and file to a server in Flutter?
body: <p>I use a web service for image processing , it works well in Postman:  </p>
  
  <p><a href="https://i.stack.imgur.com/UAHqI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UAHqI.png" alt="postman screenshot"></a>  </p>
  
  <p>Now I want to make http request in flutter with Dart:  </p>
  
  <pre><code>import 'package:http/http.dart' as http;
  
  static ocr(File image) async {
      var url = '${API_URL}ocr';
      var bytes = image.readAsBytesSync();
  
      var response = await http.post(
          url,
          headers:{ "Content-Type":"multipart/form-data" } ,
          body: { "lang":"fas" , "image":bytes},
          encoding: Encoding.getByName("utf-8")
      );
  
      return response.body;
  
    }
  </code></pre>
  
  <p>but I don't know how to upload the image file, in above code I get exception: <code>Bad state: Cannot set the body fields of a Request with content-type "multipart/form-data".</code><br>
  How should I write the body of request?</p>