copyFile static method

Future<File> copyFile(
  1. String source,
  2. String destination
)

Implementation

static Future<File> copyFile(String source, String destination) async {
  ReceivePort receivePort = ReceivePort();
  Isolate isolate = await Isolate.spawn(
    _copyFileIsolate,
    _CopyFileArguments(source, destination, receivePort.sendPort, false),
  );
  await receivePort.first;
  isolate.kill();
  var destFile = File(destination);
  if (!destFile.existsSync()) {
    throw Exception('file wasn\'t copied');
  }
  return destFile;
}