target method

  1. @override
Future<String> target()
override

Gets the target of the link.

Returns a future that completes with the path to the target.

If the returned target is a relative path, it is relative to the directory containing the link.

If the link does not exist, or is not a link, the future completes with a FileSystemException.

Implementation

@override
Future<String> target() {
  final completer = Completer<String>();
  void cb(Object? err, String target) {
    if (err != null) {
      completer.completeError(err);
    } else {
      completer.complete(target);
    }
  }

  final jsCallback = js.allowInterop(cb);
  fs.readlink(path, jsCallback);
  return completer.future;
}