flutter uploading image code example

Example: uploading image flutter

var d = "$tmpFile";
      var dd = d.split("'");
      var filename = dd[1].split('/').last;
      FormData formData = new FormData.fromMap({
        "user_id": "3225",
        "image": await MultipartFile.fromFile(dd[1], filename: "$filename"),
      });
      var response = await dio.post(
        'http://10.0.2.2/test/upload.php',
        data: formData,
        onSendProgress: (received, total) {
          if (total != -1) {
            print((received / total * 100).toStringAsFixed(0) + "%");
          }
        },
      );
      print(response);