file_directory_ext 0.1.3 copy "file_directory_ext: ^0.1.3" to clipboard
file_directory_ext: ^0.1.3 copied to clipboard

discontinuedreplaced by: path

Extend the File and Directory class to provide easy access to name and extensions

example/file_directory_ext_example.dart

import 'dart:io';

// Must be imported to allow the use of the extended properties
import 'package:file_directory_ext/file_directory_ext.dart';

void main() {
  final tempDirectory = Directory.systemTemp.createTempSync();

  // You can also use tempDirectory.basename
  print(tempDirectory.name);

  /*
  Since we also extends [FileSystemEntity] every [Directory] [Link] and [File]
  can use the .name and .basename getter

  But only a [File] or a [Link] can use the .extension getter
   */

  // Create a [File] with the system folder
  final tempFile = File(
      '${tempDirectory.path}${Platform.pathSeparator}${DateTime.now().millisecondsSinceEpoch.toString()}.tmp');

  // Display the [File] name and extension
  print(tempFile.name);
  print(tempFile.basename);
  print(tempFile.extension);

  // Same for a [Link]
  final tempLink = Link('${tempDirectory}');
  tempLink.createSync('${tempDirectory}${Platform.pathSeparator}tempLink');

  print(tempLink.name);
  print(tempLink.basename);
  print(tempLink.extension);
}
1
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Extend the File and Directory class to provide easy access to name and extensions

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

More

Packages that depend on file_directory_ext