path 1.3.5

  • Installing
  • Versions
  • 49

A comprehensive, cross-platform path manipulation library for Dart.

The path package provides common operations for manipulating paths: joining, splitting, normalizing, etc.

We've tried very hard to make this library do the "right" thing on whatever platform you run it on, including in the browser. When you use the top-level functions, it will assume the current platform's path style and work with that. If you want to explicitly work with paths of a specific style, you can construct a path.Context for that style.


The path library was designed to be imported with a prefix, though you don't have to if you don't want to:

import 'package:path/path.dart' as path;

The most common way to use the library is through the top-level functions. These manipulate path strings based on your current working directory and the path style (POSIX, Windows, or URLs) of the host platform. For example:

path.join("directory", "file.txt");

This calls the top-level [join] function to join "directory" and "file.txt" using the current platform's directory separator.

If you want to work with paths for a specific platform regardless of the underlying platform that the program is running on, you can create a [Context] and give it an explicit [Style]:

var context = new path.Context(style:;
context.join("directory", "file.txt");

This will join "directory" and "file.txt" using the Windows path separator, even when the program is run on a POSIX machine.


Where can I use this?

Pathos runs on the Dart VM and in the browser under both dart2js and Dartium. Under dart2js, it currently returns "." as the current working directory, while under Dartium it returns the current URL.

Why doesn't this make paths first-class objects?

When you have path objects, then every API that takes a path has to decide if it accepts strings, path objects, or both.

  • Accepting strings is the most convenient, but then it seems weird to have these path objects that aren't actually accepted by anything that needs a path. Once you've created a path, you have to always call .toString() on it before you can do anything useful with it.

  • Requiring objects forces users to wrap path strings in these objects, which is tedious. It also means coupling that API to whatever library defines this path class. If there are multiple "path" libraries that each define their own path types, then any library that works with paths has to pick which one it uses.

  • Taking both means you can't type your API. That defeats the purpose of having a path type: why have a type if your APIs can't annotate that they expect it?

Given that, we've decided this library should simply treat paths as strings.

How cross-platform is this?

We believe this library handles most of the corner cases of Windows paths (POSIX paths are generally pretty straightforward):

  • It understands that both "/" and "" are valid path separators, not just "".

  • It can accurately tell if a path is absolute based on drive-letters or UNC prefix.

  • It understands that "/foo" is not an absolute path on Windows.

  • It knows that "C:\foo\one.txt" and "c:/foo\two.txt" are two files in the same directory.

What is a "path" in the browser?

If you use this package in a browser, then it considers the "platform" to be the browser itself and uses URL strings to represent "browser paths".


  • Added type annotations to top-level and static fields.


  • Fix dev_compiler warnings.


  • Performance improvement in Context.relative - don't call current if from is not relative.


  • Fix some analyzer hints.


  • Add a number of performance improvements.


  • Expose a top-level context field that provides access to a Context object for the current system.


  • Don't cache path Context based on cwd, as cwd involves a system-call to compute.


  • Remove the documentation link from the pubspec so this is linked to by default.


  • Many members on Style that provided access to patterns and functions used internally for parsing paths have been deprecated.

  • Manually parse paths (rather than using RegExps to do so) for better performance.


  • Added path.prettyUri, which produces a human-readable representation of a URI.


  • path.fromUri now accepts strings as well as Uri objects.

Use this package as a library

1. Depend on it

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

  path: ^1.3.5

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:path/path.dart';
Version Uploaded Documentation Archive
1.6.2 Jul 18, 2018 Go to the documentation of path 1.6.2 Download path 1.6.2 archive
1.6.1 Jun 13, 2018 Go to the documentation of path 1.6.1 Download path 1.6.1 archive
1.6.0 Jun 5, 2018 Go to the documentation of path 1.6.0 Download path 1.6.0 archive
1.5.1 Nov 21, 2017 Go to the documentation of path 1.5.1 Download path 1.5.1 archive
1.5.0 Nov 7, 2017 Go to the documentation of path 1.5.0 Download path 1.5.0 archive
1.4.2 Jun 8, 2017 Go to the documentation of path 1.4.2 Download path 1.4.2 archive
1.4.1 Dec 8, 2016 Go to the documentation of path 1.4.1 Download path 1.4.1 archive
1.4.0 Oct 10, 2016 Go to the documentation of path 1.4.0 Download path 1.4.0 archive
1.3.9 Dec 2, 2015 Go to the documentation of path 1.3.9 Download path 1.3.9 archive
1.3.8 Dec 1, 2015 Go to the documentation of path 1.3.8 Download path 1.3.8 archive

All 63 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.

This package version is not analyzed, because it is more than two years old. Check the latest stable version for its analysis.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Maintenance issues and suggestions

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0