title: Get The Image variable from the File Path and upload to backend in FileFormat in Flutter
body: <p>I'm new to flutter and in an app I'm building I use ImagePicker plugin.
  with that the file path image is viewed in my app after I get it from camera/gallery.
  the image.path is like this</p>
  <p>/storage/emulated/0/Android/data/.../files/Pictures/234d9437-8652-48de-a2b6-711b5f8b702d3492716976084944343.jpg</p>
  <p>I need to get the image &quot;234d9437-8652-48de-a2b6-711b5f8b702d3492716976084944343.jpg&quot; part from that and send it to a backend db. I need to convert this before sending. Backend only accept Images in FileFormat.</p>
  <p>How can get the image from the file path. in this case it's the variable _imageURI. Then from that retrieve the image and convert it into a FileFormat. After that I need to pass it to a Backend using a json POST request.</p>
  <p>In my json request I have a field for 'image': that I need to set the value got from image selected in file format and set to there. how can do this?
  can someone explain me with a code ?
  much appreciated.</p>
  <p><em><strong>My Code</strong></em></p>
  <pre><code>File _imageURI;
  Future _getImageFromCamera() async {
  var petImage = await ImagePicker.pickImage(source: ImageSource.camera); //or gallery
  setState(() {
        _imageURI = petImage;
        print(_imageURI.path);
    }
  }
  </code></pre>
  <p><em><strong>Image Viewed as</strong></em></p>
  <pre><code>Container(
    width: 120.0,
    height: 120.0,
    decoration: new BoxDecoration(
      shape: BoxShape.circle,
      image: new DecorationImage(
        fit: BoxFit.cover,
        image: new FileImage(
          _imageURI,
          scale: 1.0,
        ),
      ),
    ),
  ),
  </code></pre>
  <p><em><strong>Json Request</strong></em></p>
  <pre><code>dogData = {
   {
    &quot;user_email&quot;: &quot;email@m.com,
    &quot;user_token&quot;: &quot;thisistoken&quot;,
    &quot;pet&quot;: {
      &quot;age&quot;: &quot;integer&quot;,
      &quot;birth_date&quot;: &quot;%d %b %Y (01 JAN 1996)&quot;,
      &quot;image&quot;: &quot;!Swagger doesn't allow to put file upload. Use formdata instead of base64 in frontend module.&quot;,
      &quot;name&quot;: &quot;string&quot;,
      &quot;sex&quot;: &quot;string&quot;,
      &quot;user_id&quot;: &quot;id&quot;
    }
  }
  </code></pre>
  <p><em><strong>My API call</strong></em></p>
  <pre><code>final pet = await CallApi().createThePet(dogData, 'pets/create');
  ////
  Future&lt;dynamic&gt; createThePet(data, apiUrl) async{
      var fullUrl = _baseUrl + apiUrl; // + await _getToken();
      final response = await http.post(fullUrl, body: jsonEncode(data), headers: _setHeaders());
  ....
  </code></pre>