2

I want to get gallery folder path.

I tried to use multiple libraries [path_provider, storage_path, image_save, multi_image_picker ...] to get the gallery folder path, but none of the libraries got the gallery folder path.

Alok
  • 8,452
  • 13
  • 55
  • 93
Hưng Trịnh
  • 947
  • 1
  • 12
  • 23
  • What is your end goal, to get the path, or to get the file from gallery? – Alok Aug 03 '20 at 06:46
  • save image & video and check file exists – Hưng Trịnh Aug 03 '20 at 07:35
  • Try this https://pub.dev/packages/storage_path – Filip Aug 03 '20 at 07:35
  • He has tried it @Filip Same has been mentioned in his question :) – Alok Aug 03 '20 at 07:36
  • @Alok I guess it's impossible to get the path to the gallery itself. If I understand the gallery correctly, it is something like the application itself, and you can get only the path to the folders contained in it or the files themselves. – Filip Aug 03 '20 at 07:46
  • Yeah, even I am trying to figure something out for this @Filip It is fairly impossible to do that right now, but there is always a work around which can be followed. Hence I am searching for it. – Alok Aug 03 '20 at 07:47
  • @Alok Plase check this answere https://stackoverflow.com/a/61011335/12037365 – Mr vd Aug 03 '20 at 10:20

1 Answers1

0

See, I don't find any great thing to save your file to your gallery, what I did found is to how to get your things done.

My solution will give you some things like

  • Save a file visible to the user
  • Check whether the file exists or not

Saving the file:

Check whether the file exists or not

To do this, you can use this code inside your code, where you are trying to save the file, form the above answer.

Important: You will get the path of the file where you are storing the file, just pass the path in the below code

import 'dart:io' as io;

// for a file
bool exists = io.File(path).exists();

// for a directory
bool exists = io.Directory(path).exists();

if(exists) // do your operation
else // do your else operation

I am able to produce this much content for your problem. Any feedback are welcomed.

Alok
  • 8,452
  • 13
  • 55
  • 93
  • worked on android but error on IOS please see bug: https://imgur.com/ZP1Mz6l – Hưng Trịnh Aug 03 '20 at 10:30
  • Yeah @HưngTrịnh so `iOS`, I have already shared the answer, in which he has mentioned what to do for iOS as well. This is the link: https://stackoverflow.com/a/59629863/5362583. It is already there under **Saving the file** `Point number 2`. Let me know if that works out for you :) – Alok Aug 03 '20 at 10:51
  • i use ```getApplicationDocumentsDirectory``` from **path_provider** . File saved but it not in gallery. path save current: ```on Iphone > myapp > image_download. ``` – Hưng Trịnh Aug 03 '20 at 10:56
  • That means you are able to get what you want, right @HưngTrịnh ? – Alok Aug 03 '20 at 11:06
  • no, now file has downloaded and can view on system app: ```File``` but i want to save image and view image on gallery – Hưng Trịnh Aug 03 '20 at 11:08
  • 1
    Yeah, that is why I mentioned that thing, that I came up with this sorta solution, cos this is the best which is available for you. You can keep exploring your way to search for the desired result. Till the time, you can make use of this answer. Thanks @HưngTrịnh :) – Alok Aug 03 '20 at 11:10