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);
  });
}
1
likes
160
pub points
17%
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