openDownloadFolder method

  1. @override
Future<bool> openDownloadFolder()
override

Implementation

@override
Future<bool> openDownloadFolder() async {
  if (Platform.isAndroid || Platform.isIOS) {
    // Open the download folder directly on Android and iOS using the platform-specific channel.
    final result =
        await methodChannel.invokeMethod<bool?>('openDownloadFolder');
    return result ?? false;
  }

  // For other platforms, retrieve the download folder path and attempt to launch the file explorer or file manager.
  final downloadDirectory = await getDownloadFolder();
  final downloadPath = Platform.isMacOS || Platform.isLinux
      ? 'file://${downloadDirectory.path}'
      : downloadDirectory.path;

  return _openDesktopFolder(downloadPath);
}