copy_ method

Future<void> copy_(
  1. String destination
)

Copies the File to the specified destination.

Implementation

Future<void> copy_(String destination) async {
  try {
    // Delete if some [File] or [Directory] already exists at the [destination].
    try {
      if (await File(addPrefix(destination)).exists_()) {
        await File(addPrefix(destination)).delete_();
      }
    } catch (exception, stacktrace) {
      print(exception.toString());
      print(stacktrace.toString());
    }
    try {
      if (await Directory(addPrefix(destination)).exists_()) {
        await Directory(addPrefix(destination)).delete_();
      }
    } catch (exception, stacktrace) {
      print(exception.toString());
      print(stacktrace.toString());
    }
    await File(addPrefix(path)).copy(addPrefix(destination));
  } catch (exception, stacktrace) {
    print(exception.toString());
    print(stacktrace.toString());
  }
}