Flutter-如何打开以前在图库中创建的文件夹

问题描述 投票:0回答:1

我在flutter项目中成功使用save_in_gallery: ^0.1.3包将图像保存到图库。

完成后,我将显示一个对话框,询问用户是否要打开文件。

如何从“打开” FlatButton打开'Flutter Images'文件夹?

((我需要打开文件夹,因为您无法在iOS中命名图像文件,所以我希望用户打开该文件夹并可以查看所有已保存的图像)

await ImageSaver().saveImages(
        imageBytes: [pngBytes], directoryName: 'Flutter Images').then((onValue) {
      if (onValue) {
        showDialog(
            context: context,
            builder: (BuildContext context) {
              return AlertDialog(
                title: Text('Saved Completed'),
                content: Text('Do you want to open your file?'),
                actions: <Widget>[
                  FlatButton(
                    child: Text('Open'),
                    onPressed: () {}, //---> OPEN FOLDER FROM HERE <---
                  ),
                  FlatButton(
                    child: Text('Close'),
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                  )
                ],
              );
            })


[pngBytes是我实际上保存在图库内的'Flutter Images'文件夹中的Uint8List。


flutter dialog gallery
1个回答
0
投票

您可以使用https://pub.dev/packages/open_file库从存储中打开任何文件。

OpenFile.open("path_to_file_here");

例如

OpenFile.open("/sdcard/Flutter Images/image.png");

© www.soinside.com 2019 - 2024. All rights reserved.