title: Flutter : Save picture in asset folder from android emulator and post it to API
body: <p>Hi guys I'm a beginner in flutter, I have a picture in android emulator gallery and I'm trying to update my user's profile picture through an API .</p>
  <p>My API function :
  this is the way I'm updating it (by the way the phone field is getting updated and the image is not)
  I'm receiving a status code of 200</p>
  <pre><code>Future&lt;Provider&gt; updateProviderInfo(Provider person) async {
  
   person.idUser = await FlutterSession().get(&quot;id&quot;);
  final response = await http.put(
    Uri.parse(ApiConstants.BASE_URL + ApiConstants.UPDATE_PROVIDER),
    headers: &lt;String, String&gt;{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: jsonEncode(&lt;String, String&gt;{
      'providerId': person.idUser.toString(),
      'providerProfilePicture': person.providerProfilePicture,
      'phone' :&quot;92211130030&quot;
    }),
  );
  if (response.statusCode == 200) {
    // If the server did return a 200 OK response,
    // then parse the JSON.
    Fluttertoast.showToast(
        msg: &quot;Updated with success&quot;,
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.CENTER,
        timeInSecForIosWeb: 1,
        backgroundColor: Colors.blue,
        textColor: Colors.white,
        fontSize: 16.0);
    return Provider.fromJson(jsonDecode(response.body));
  } else {
    // If the server did not return a 200 OK response,
    // then throw an exception.
    throw Exception('Failed to update User Type :Service Provider.');
  }}
  </code></pre>
  <p>How I'm loading my image:</p>
  <p>This is the way im getting the Image from emulator's Gallery or camera :</p>
  <pre><code> Future&lt;File&gt; _loadImage(ImageSource imageSource) async {
  
  PickedFile file = await _imagePicker.getImage(source: imageSource,imageQuality: 50, // &lt;- Reduce Image quality
      maxHeight: 250,  // &lt;- reduce the image size
      maxWidth: 250);
  File mFile;
  
  if (null != file) {
    Directory directory = await getTemporaryDirectory();
    //mFile = await _saveImageToDisk(file.path, directory);
    Map map = Map();
    map['path'] = file.path;
    String myLastFilePath = file.path.substring(file.path.indexOf(&quot;picker&quot;));
    print (&quot;my try : &quot;+myLastFilePath);
  
    provider.providerProfilePicture = myLastFilePath;
    print(&quot;my path :  &quot;+provider.providerProfilePicture);
    map['directory'] = directory;
    mFile = await compute(_saveImageToDisk, map);
  }
  return mFile; }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/RxdZE.png" rel="nofollow noreferrer">this is how my view looks like</a></p>
  <p>I'm receiving a 200 status code and the phone number is getting updated but the image field in DB is empty</p>
  <p><a href="https://i.stack.imgur.com/Ub9XS.png" rel="nofollow noreferrer">my Route API test in postman</a></p>
  <p>I think I should use a multiPartFormData but I have no idea how to use it and I'm not sure any guidance will be appreciated thank you</p>