isolate_current_directory 2.0.0 copy "isolate_current_directory: ^2.0.0" to clipboard
isolate_current_directory: ^2.0.0 copied to clipboard

Support for isolated Directory.current. Use the `withCurrentDirectory` function to change the Dart current directory within a scope without affecting the global one.

example/isolate_current_directory_example.dart

import 'dart:io';

import 'package:isolate_current_directory/isolate_current_directory.dart';

void main() {
  withCurrentDirectory('lib', () async {
    // File and Directory created within "withCurrentDirectory"
    // will use 'lib' as the working directory.
    final src = Directory('src');
    print('Directory src exists? ${await src.exists()}');
    await src.list(recursive: true).forEach((child) => print(' * $child'));

    // But Process methods do not currently respect Directory.current,
    // so the working directory must be explicitly provided.
    final ls = await Process.run('ls', const [],
        workingDirectory: Directory.current.path);
    print('Result of running "ls" at ${Directory.current}');
    stdout.write(ls.stdout);
    stderr.write(ls.stderr);
  });
}
0
likes
140
pub points
3%
popularity

Publisher

unverified uploader

Support for isolated Directory.current. Use the `withCurrentDirectory` function to change the Dart current directory within a scope without affecting the global one.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

path

More

Packages that depend on isolate_current_directory