openFolder method

  1. @override
Future<OpenResult> openFolder(
  1. String folderPath
)
override

Opens a folder at the specified path

folderPath - The path to the folder to open Returns OpenResult indicating success or failure

Implementation

@override
Future<OpenResult> openFolder(String folderPath) async {
  // For desktop platforms, use native system commands
  if (!Platform.isIOS && !Platform.isAndroid) {
    return _openFolderDesktop(folderPath);
  }

  // For mobile platforms, use method channel
  try {
    final Map<String, String> arguments = {'folder_path': folderPath};

    final result = await methodChannel.invokeMethod<String>(
      'openFolder',
      arguments,
    );

    if (result != null) {
      final resultMap = json.decode(result) as Map<String, dynamic>;
      return OpenResult.fromJson(resultMap);
    } else {
      return const OpenResult(
        type: ResultType.error,
        message: 'Failed to open folder: No response from platform',
      );
    }
  } on PlatformException catch (e) {
    return OpenResult(
      type: ResultType.error,
      message: 'Failed to open folder: ${e.message}',
    );
  } catch (e) {
    return OpenResult(
      type: ResultType.error,
      message: 'Failed to open folder: $e',
    );
  }
}