saveCopy static method

Future<XFileSaveStatus> saveCopy({
  1. required String path,
  2. String? mimeType,
})

Save a user-visible copy of the file at path.

  • iOS: presents the system export picker ("Save to Files"); the user chooses the destination. Dismissal returns XFileSaveStatus.cancelled.
  • Android: inserts into the Downloads collection (API 29+, no permission needed) or copies into the public Downloads folder after a WRITE_EXTERNAL_STORAGE grant (API <29 — XFileSaveStatus.denied when refused).
  • macOS: presents an NSSavePanel and copies to the chosen destination. Dismissal returns XFileSaveStatus.cancelled.
  • Windows: presents a save dialog holding the file's name and copies to the chosen destination, over a file already there. Dismissal returns XFileSaveStatus.cancelled.

mimeType hints the MediaStore row on Android; ignored on Apple platforms.

Implementation

static Future<XFileSaveStatus> saveCopy({
  required String path,
  String? mimeType,
}) async {
  final s = await _channel.invokeMethod<String>('saveCopy', {
    'path': path,
    'mimeType': ?mimeType,
  });
  return switch (s) {
    'saved' => XFileSaveStatus.saved,
    'denied' => XFileSaveStatus.denied,
    _ => XFileSaveStatus.cancelled,
  };
}