uri 0.11.1

  • README.md
  • Installing
  • Versions
  • 79


This package contains utilities for working with URIs in Dart, mostly parsing and generating URIs.

Build Status


UriPattern is an interface for classes that match and parse URIs, much like the Pattern is for Strings. It defines the methods bool matches(Uri uri) and UriMatch match(Uri uri).


UriMatch is the result of UriPattern.match(). It contains the parameters parsed out of a URI and the "rest" of the URI left over after parsing, which is useful for parsing a single URI with multiple relative URI patterns that form a hierarchy.


UriTemplate is an implementation of RFC 6570 URI Templates. URI Templates are useful for generating URIs from data. UriTemplates are created from a template string, and then expanded with data to generate a URI:

var template = new UriTemplate("http://example.com/~{user}/");
String fredUri = template.expand({'user': 'fred'});
print(fredUri); // prints: http://example.com/~fred/


URI templates are strings made up of fixed and variable parts. The variable parts are described with expressions, which are places within single curly-braces: { and }.

Expressions consist of an optional operator and a comma-separated list of variable_specifications. Variable specifications consist of a variable name and an optional modifier. The operator applies to the whole expression and controls how reserved characters are expanded, the prefix and separator, if any, applied to the expansion, and whether to expand the variable as a key/value pair. Modifiers apply to each variable in the expression and allow truncating the value, or "exploding" list and maps into multiple key/value pairs.


  • http://example.com/~{username}/
  • http://example.com/dictionary/{term:1}/{term}
  • http://example.com/search{?q,lang}


URI template expansions does more than simple variable replacement, it has facilities for generating paths, fragments, query strings and more. To control the expansion, expressions can use one of the supported operators:

noneSimple string expansion
+Reserved string expansion
#Fragment expansion
.Label expansion, dot-prefixed
/Path segments, slash-prefixed
;Path-style parameters, semicolon-prefixed
?Form-style query, ampersand-separated
&Form-style query continuation


Modifiers control

noneDefault expansion
:nPrefix: use only the first n characters o the value
*"Explode" the lists and maps into key/value pairs


UriParser parses URIs according to a UriTemplate, extracting paramaters based on the variables defined in the template.

Since URI Templates are not designed to be parsable, only a restricted subset of templates can be used for parsing.

Parsable templates have the following restrictions over expandable templates:

  • URI components must come in order: scheme, host, path, query, fragment. There can only be one of each component.
  • Path expressions can only contain one variable.
  • Multiple expressions must be separated by a literal.
  • Only the following operators are supported: none, +, #, ?, &
  • Default and + operators are not allowed in query or fragment components.
  • Queries can only use the ? or & operator.
  • The ? operator can only be used once.
  • Fragments can only use the # operator


UriBuilder is mutable container of URI components for incrementally building Uris.


  • Widen dependency on package:quiver


  • Migrate from the unittest to the new test package.


  • Widen dependency on quiver
  • Widen dependency on matcher


  • Preserve query parameters in UriMatch.rest

1. Depend on it

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

  uri: "^0.11.1"

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:uri/uri.dart';
Version Uploaded Documentation Archive
0.11.1 Aug 1, 2017 Go to the documentation of uri 0.11.1 Download uri 0.11.1 archive
0.11.0 Aug 10, 2015 Go to the documentation of uri 0.11.0 Download uri 0.11.0 archive
0.10.0 May 21, 2015 Go to the documentation of uri 0.10.0 Download uri 0.10.0 archive
0.9.5 Jan 14, 2015 Go to the documentation of uri 0.9.5 Download uri 0.9.5 archive
0.9.3 Jun 28, 2014 Go to the documentation of uri 0.9.3 Download uri 0.9.3 archive
0.9.2 May 25, 2014 Go to the documentation of uri 0.9.2 Download uri 0.9.2 archive
0.9.1 Apr 24, 2014 Go to the documentation of uri 0.9.1 Download uri 0.9.1 archive
0.9.0 Mar 3, 2014 Go to the documentation of uri 0.9.0 Download uri 0.9.0 archive
0.8.0 Dec 27, 2013 Go to the documentation of uri 0.8.0 Download uri 0.8.0 archive
0.7.1 Dec 27, 2013 Go to the documentation of uri 0.7.1 Download uri 0.7.1 archive

All 11 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 14, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


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


Detected platforms: Flutter, web, other

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


  • Fix lib/src/uri_template.dart.

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

    line: 232 col: 35
    The return type 'void' isn't a 'String', as defined by anonymous closure.

  • Fix lib/matchers.dart.

    Strong-mode analysis of lib/matchers.dart failed with the following error:

    line: 119 col: 3
    Invalid override. The type of '_CompoundMatcher.matches' ('(T, Map<dynamic, dynamic>) → bool') isn't a subtype of 'Matcher.matches' ('(dynamic, Map<dynamic, dynamic>) → bool').

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 2 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.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • 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 uri.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.12.0
matcher >=0.12.0 <0.13.0 0.12.1+4
quiver >=0.17.0 <0.26.0 0.25.0 0.28.0
utf >=0.8.10 <=0.10.0 0.9.0+4
Transitive dependencies
path 1.5.1
stack_trace 1.9.2
Dev dependencies
test >=0.12.0 <=0.13.0