Upload multiple images and compress image in Flutter
In this article, I will demonstrate how to upload multiple images and compress image in your Flutter App.
There are some required libs in order to solve this problem:
Get images from gallery
Convert List<Asset> to List<File>
From multi_image_picker lib, it returns List<Asset>. However, flutter_image_compress can compress File. Letโs convert List<Asset> to List<File>
Image Compress Service
Letโs create image_compress_service to generate image path and compress image.
Generate FormData
In order to upload file, we need to generate it to FormData
Upload Images to Server
After generating FormData from above method, here is the final step.
Finally, we can upload compressed images to the server successfully. Please give me some claps ๐๐๐๐ if you like this article.
Check out full source code here: full_source_code