file 5.0.7

  • Installing
  • Versions
  • 92

Build Status pub package


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


  • Dart 2 fixes for RecordingProxyMixin and ReplayProxyMixin.


  • Dart 2 fixes for


  • Dart 2 fixes


  • Update SDK constraint to 2.0.0-dev.67.0, remove workaround in recording_proxy_mixin.dart.
  • Fix usage within Dart 2 runtime mode in Dart 2.0.0-dev.61.0 and later.
  • Relax constraints on package:test


  • Update package:test dependency to 1.0


  • Declare compatibility with Dart 2 stable


  • Remove upper case constants
  • Update SDK constraint to 2.0.0-dev.54.0.


  • Moved testing library into a dedicated package:file_testing so that libraries don't need to take on a transitive dependency on package:test in order to use package:file.



  • Change method signature for RecordingRandomAccessFile._close to return a Future<void> instead of Future<RandomAccessFile>. This follows a change in dart:io, Dart SDK 2.0.0-dev.40.


  • Import dart:io unconditionally. More recent Dart SDK revisions allow dart:io to be imported in a browser context, though if methods are actually invoked, they will fail. This matches well with package:file, where users can use the memory library and get in-memory implementations of the dart:io interfaces.
  • Bump minimum Dart SDK to 1.24.0


  • Fix Dart 2 error.


  • 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

Use this package as a library

1. Depend on it

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

  file: ^5.0.7

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 flutter 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
5.0.7 Dec 7, 2018 Go to the documentation of file 5.0.7 Download file 5.0.7 archive
5.0.6 Aug 30, 2018 Go to the documentation of file 5.0.6 Download file 5.0.6 archive
5.0.5 Aug 29, 2018 Go to the documentation of file 5.0.5 Download file 5.0.5 archive
5.0.4 Aug 14, 2018 Go to the documentation of file 5.0.4 Download file 5.0.4 archive
5.0.3 Aug 13, 2018 Go to the documentation of file 5.0.3 Download file 5.0.3 archive
5.0.2 Aug 13, 2018 Go to the documentation of file 5.0.2 Download file 5.0.2 archive
5.0.1 May 21, 2018 Go to the documentation of file 5.0.1 Download file 5.0.1 archive
5.0.0 Apr 10, 2018 Go to the documentation of file 5.0.0 Download file 5.0.0 archive
4.0.1 Apr 10, 2018 Go to the documentation of file 4.0.1 Download file 4.0.1 archive
4.0.0 Apr 6, 2018 Go to the documentation of file 4.0.0 Download file 4.0.0 archive

All 27 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Dec 7, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7


Detected platforms: Flutter, other

Primary library: package:file/file.dart with components: io.

Maintenance suggestions

The description is too short. (-20 points)

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. (-10 points)

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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.67.0 <3.0.0
intl >=0.14.0 <0.16.0 0.15.7
meta ^1.1.2 1.1.6
path ^1.5.1 1.6.2
Dev dependencies
file_testing >=2.0.0 <3.0.0
test >=1.0.0 <2.0.0