Reputation: 397
The function I want to achieve is to open the SD card directory after clicking a button, then I can select a PPT file, it will call the machine to view the PPT software to open, how can I achieve this function?
Upvotes: 2
Views: 1796
Reputation: 2621
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();
}
Upvotes: 1