rename_ method

Future<void> rename_(
  1. String destination
)

Renames the File to the specified destination.

Implementation

Future<void> rename_(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)).rename(addPrefix(destination));
  } catch (exception, stacktrace) {
    print(exception.toString());
    print(stacktrace.toString());
  }
}