file 2.3.6

  • Installing
  • Versions
  • 87

Build Status Coverage Status


A generic file system abstraction for Dart.

Like dart:io, package:file supplies a rich Dart-idiomatic API for accessing a file system.

Unlike dart:io, package:file:

  • Can be used to implement custom file systems.
  • Comes with an in-memory implementation out-of-the-box, making it super-easy to test code that works with the file system.
  • Allows using multiple file systems simultaneously. A file system is a first-class object. Instantiate however many you want and use them all.


Implement your own custom file system:

import 'package:file/file.dart';

class FooBarFileSystem implements FileSystem { ... }

Use the in-memory file system:

import 'package:file/memory.dart';

var fs = new MemoryFileSystem();

Use the local file system (requires dart:io access):

import 'package:file/local.dart';

var fs = const LocalFileSystem();


  • Relax sdk upper bound constraint to '<2.0.0' to allow 'edge' dart sdk use.


  • Fix internal use of a cast which fails on Dart 2.0 .


  • Bumped maximum Dart SDK version to 2.0.0-dev.infinity


  • Relaxes version requirements on package:intl


  • Fixed, FileSystem.file(Uri), and to consult the file system's path context when converting the URI to a file path rather than using Uri.toFilePath().


  • Fixed MemoryFileSystem to make File.writeAs...() update the last modified time of the file.


  • Added the following convenience methods in Directory:
    • Directory.childDirectory(String basename)
    • Directory.childFile(String basename)
    • Directory.childLink(String basename)


  • Added ErrorCodes class, which holds errno values.


  • Add support for new dart:io API methods added in Dart SDK 1.23


  • Minor doc updates


  • Improved toString implementations in file system entity classes
  • Added ForwardingFileSystem and associated forwarding classes to the main file library
  • Removed FileSystem.pathSeparator, and added a more comprehensive FileSystem.path property
  • Added FileSystemEntity.basename and FileSystemEntity.dirname
  • Added the record_replay library
  • Added the testing library


  • Added FileSystem.systemTempDirectory
  • Added the ability to pass Uri and FileSystemEntity types to, FileSystem.file(), and
  • Added FileSystem.pathSeparator


  • Unified interface to match dart:io API
  • Local file system implementation
  • In-memory file system implementation
  • Chroot file system implementation


  • Initial version

1. Depend on it

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

  file: "^2.3.6"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:file/file.dart';
Version Uploaded Documentation Archive
2.3.6 Feb 12, 2018 Go to the documentation of file 2.3.6 Download file 2.3.6 archive
2.3.5 Nov 22, 2017 Go to the documentation of file 2.3.5 Download file 2.3.5 archive
2.3.4 Jul 13, 2017 Go to the documentation of file 2.3.4 Download file 2.3.4 archive
2.3.3 Jul 11, 2017 Go to the documentation of file 2.3.3 Download file 2.3.3 archive
2.3.2 Mar 27, 2017 Go to the documentation of file 2.3.2 Download file 2.3.2 archive
2.3.1 Mar 15, 2017 Go to the documentation of file 2.3.1 Download file 2.3.1 archive
2.3.0 Feb 27, 2017 Go to the documentation of file 2.3.0 Download file 2.3.0 archive
2.2.0 Feb 22, 2017 Go to the documentation of file 2.2.0 Download file 2.2.0 archive
2.1.0 Feb 21, 2017 Go to the documentation of file 2.1.0 Download file 2.1.0 archive
2.0.1 Feb 12, 2017 Go to the documentation of file 2.0.1 Download file 2.0.1 archive

All 15 versions...


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Feb 16, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
87 / 100
Code health derived from static analysis. [more]
90 / 100
Reflects how tidy and up-to-date the package is. [more]
85 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:file/file.dart.


  • Fix lib/src/backends/local/local_file.dart.

    Strong-mode analysis of lib/src/backends/local/local_file.dart failed with the following error:

    line: 8 col: 10
    The class 'ForwardingFile' can't be used as a mixin because it extends a class other than Object.

  • Fix lib/src/backends/local/local_directory.dart.

    Strong-mode analysis of lib/src/backends/local/local_directory.dart failed with the following error:

    line: 9 col: 10
    The class 'ForwardingDirectory' can't be used as a mixin because it extends a class other than Object.

  • Fix further 6 Dart files.

    Similar analysis of the following files failed:

    • lib/src/backends/local/local_link.dart
    • lib/src/backends/chroot/chroot_link.dart
    • lib/src/backends/chroot/chroot_file.dart
    • lib/src/backends/chroot/chroot_directory.dart
    • lib/src/testing/core_matchers.dart
    • lib/src/testing/record_replay_matchers.dart
  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 3 error(s) and 0 warning(s).

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use file.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <2.0.0
intl >=0.14.0 <0.16.0 0.15.2
meta ^1.0.4 1.1.2
path ^1.4.0 1.5.1
Dev dependencies
test ^0.12.18