dir_utils 1.0.0 copy "dir_utils: ^1.0.0" to clipboard
dir_utils: ^1.0.0 copied to clipboard

A Dart package to add handy methods to Directory class

example/dir_utils_example.dart

import 'dart:io';

import 'package:dir_utils/dir_utils.dart';

void main() {
  // Traverse through directories
  final File file = Directory.current
      .dir('very')
      .dir('deep')
      .dir('nested')
      .dir('dir')
      .dir('and')
      .file('file');

  // Get the files in the current directory
  final List<File> files = Directory.current.getFiles().toList();

  // Create the file and ancestor directories if they don't exist
  file.createSync(recursive: true);

  // Name of the current directory
  file.writeAsStringSync('Files in ${Directory.current.name}');

  // Write the name of the files in the current directory
  file.writeAsStringSync(
    files.map((e) => e.name).toList().join('\n'),
    mode: FileMode.append,
  );
}
0
likes
160
points
28
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart package to add handy methods to Directory class

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on dir_utils