4

I'm using the image picker plugin for flutter. Whenever I pick an image from the gallery, it is assigned a random name by the plugin, starting with 'image_picker.' How can I get the original name of the image file?

6
  • you cannot - every time a new temporary image is created (at least under android) - github.com/flutter/plugins/blob/… Commented Jul 7, 2020 at 7:32
  • You can change the file name if you are going to store it in firebase storage. Are you trying to do that? Commented Jul 7, 2020 at 8:05
  • Yes @HardikKumar. But the issue is that I want to store the images by their original name. Commented Jul 7, 2020 at 14:19
  • did you solve this? I am getting same issue Commented Nov 24, 2020 at 12:17
  • 1
    I have the same problem with Rest API to which I need to send image files (via Base64) which are name exactly as required by the API. Any ideas? Commented Nov 27, 2020 at 10:13

1 Answer 1

1

You can use method as mentioned below. It worked for me

var video = (await _picker.getVideo(source: ImageSource.gallery))!;

var videoName = video.path.split('/').last;
Sign up to request clarification or add additional context in comments.

1 Comment

This answer does not make sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.