rename method

  1. @override
Future<Directory> rename(
  1. String newPath
)
override

Renames this file system entity.

Returns a Future<FileSystemEntity> that completes with a FileSystemEntity instance for the renamed file system entity.

Implementation

@override
Future<file.Directory> rename(String newPath) {
  final completer = Completer<Directory>();
  void callback(Object? err) {
    if (err == null) {
      completer.complete(Directory(newPath));
    } else {
      completer.completeError(err);
    }
  }

  final jsCallback = js.allowInterop(callback);

  fs.rename(path, newPath, jsCallback);
  return completer.future;
}