Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Flutter, How to open a folder in native file explorer for the user, so that the user can browse its files/folders

I am building a file locker app in flutter which can lock files as well a folders. When a user unlocks a folder I want my app to show an option to view folder contents but in native file explorer. Is there any way to implement this feature?

(Thanks in advance..)

like image 444
Rituraj Shakti Avatar asked Nov 24 '20 07:11

Rituraj Shakti


People also ask

How do I read a folder in flutter?

To list all the files or folders, you have to use flutter_file_manager, path, and path_provider_ex flutter package. Add the following lines in your pubspec. yaml file to add this package in your dependency. Add read / write permissions in your android/app/src/main/AndroidManifest.


Video Answer


1 Answers

You can try this package for the use case you've mentioned: open_file

Usage:

import 'package:open_file/open_file.dart';
import 'package:path_provider/path_provider.dart';

//Get the path to the directory
final String dir = (await getTemporaryDirectory()).path;

//Use the path to launch the directory with the native file explorer
await OpenFile.open('$dir\\');

(Note: Tested on windows OS only)

like image 162
sj_959 Avatar answered Oct 08 '22 05:10

sj_959