open static method
Opens the file downloaded by download task with taskId
. Returns true if
the downloaded file can be opened, false otherwise.
On Android, there are two requirements for opening the file:
- The file must be saved in external storage where other applications have permission to read the file
- There must be at least 1 application that can read the files of type of the file.
Implementation
static Future<bool> open({required String taskId}) async {
assert(_initialized, 'plugin flutter_downloader is not initialized');
bool? result;
try {
result = await _channel.invokeMethod<bool>(
'open',
{'task_id': taskId},
);
if (result == null) {
throw const FlutterDownloaderException(message: '`open` returned null');
}
} on PlatformException catch (err) {
_log('Failed to open downloaded file. Reason: ${err.message}');
}
return result ?? false;
}