file_directory_ext 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new62

A simple library that extend the Directory and File classes to add easy access to name and extensions

Usage #

A simple usage example:

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);
}


0.0.1 #

  • Initial version

0.1.0 #

  • Added extension for Directory
  • Added extension for Link
  • Added extension for FileSystemEntity
  • Modified the lib internal architecture
  • Renamed files to have more logical name

0.1.1 #

  • Added experimental support for moving a directory into a parent directory with the same name
  • Added Tests

0.1.2 #

  • Added support for dart:html file (name, basename, extension)

0.1.3 #

  • Typo in HTML export

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);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  file_directory_ext: ^0.1.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:file_directory_ext/file_directory_ext.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
24
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Jul 6, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Analysis suggestions

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:file_directory_ext/file_directory_ext.dartpackage:file_directory_ext/src/extensions/link_io_extension.dartdart:io

Package not compatible with runtime web

Because of the import of dart:io via the import chain package:file_directory_ext/file_directory_ext.dartpackage:file_directory_ext/src/extensions/link_io_extension.dartdart:io

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.8.1 <3.0.0
Dev dependencies
pedantic ^1.9.0
test ^1.14.4