openFile static method
打开文件
Implementation
static Future<OpenResult> openFile(
String path, {
String? type,
String? uti,
String linuxDesktopName = "xdg",
}) async {
try {
OpenResult res = await OpenFilex.open(path, type: type, uti: uti, linuxDesktopName: linuxDesktopName);
String suffixName = UtilPath.getFileSuffix(path) ?? '';
switch (res.type) {
case ResultType.noAppToOpen:
CustomToast.showNotificationError(title: 'openFileNoAppToOpen'.tr(args: [suffixName]));
return res;
case ResultType.fileNotFound:
CustomToast.showNotificationError(title: 'openFileFileNotFound'.tr());
return res;
case ResultType.permissionDenied:
CustomToast.showNotificationError(title: 'openFilePermissionDenied'.tr(args: [suffixName]));
return res;
case ResultType.error:
CustomToast.showNotificationError(title: 'openFileError'.tr(args: [suffixName]));
return res;
case ResultType.done:
return res;
}
} catch (e, s) {
LogService.instance.reportError('打开文件', e, s);
return OpenResult(type: ResultType.error);
}
}