How to open the SD card directory to select a file with Flutter? How to open the SD card directory to select a file with Flutter? dart dart

How to open the SD card directory to select a file with Flutter?


As @anmol.majhail mentioned in a comment earlier, use the flutter_document_picker plugin:

final String pptPath = await FlutterDocumentPicker.openDocument(  params: FlutterDocumentPickerParams(    allowedFileExtensions: ['ppt'],    allowedMimeType: 'application/vnd.ms-powerpoint',    allowedUtiTypes: ['com.microsoft.powerpoint.​ppt'],  ));

Once you have the file path, use the android_intent plugin to open it in a viewer app such as WPS Office:

if (platform.isAndroid) {  final AndroidIntent intent = AndroidIntent(    action: 'action_view',    data: Uri.file(pptPath).toString(),    arguments: {},    package: 'cn.wps.moffice_eng', // optional  );  await intent.launch();}