openFile static method
Open file with system default application
Returns true if the file was successfully opened, false otherwise. On Android, uses Intent.ACTION_VIEW to open the file. On iOS, uses UIDocumentInteractionController to open the file.
Implementation
static Future<bool> openFile(String filePath) async {
try {
if (!Platform.isAndroid && !Platform.isIOS) {
throw UnsupportedError('File opening only supports Android and iOS');
}
// Check if file exists
final file = File(filePath);
if (!file.existsSync()) {
debugPrint('FilePicker.openFile: File does not exist: $filePath');
return false;
}
return await FilePickerPlatform.openFile(filePath);
} catch (e) {
debugPrint('FilePicker.openFile error: $e');
return false;
}
}