angel_route 2.0.7

  • Installing
  • Versions
  • 75


Pub build status

A powerful, isomorphic routing library for Dart.

This API is a huge improvement over the original Angel routing system, and thus deserves to be its own individual project.

angel_route exposes a routing system that takes the shape of a tree. This tree structure can be easily navigated, in a fashion somewhat similar to a filesystem. The Router API is a very straightforward interface that allows for your code to take a shape similar to the route tree. Users of Laravel and Express will be very happy.

angel_route does not require the use of Angel, and has no dependencies. Thus, it can be used in any application, regardless of framework. This includes Web apps, Flutter apps, CLI apps, and smaller servers which do not need all the features of the Angel framework.




If you use Angel, every Angel instance is a Router in itself.

main() {
  final router = new Router();
  router.get('/users', () {});'/users/:id/timeline', (String id) {});
  router.get('/square_root/:id([0-9]+)', (n) { 
    return { 'result': pow(int.parse(n), 0.5) };
  });'/show/:id', (router) {
    router.get('/reviews', (id) {
      return someQuery(id).reviews;
    // Optionally restrict params to a RegExp
    router.get('/reviews/:reviewId([A-Za-z0-9_]+)', (id, reviewId) {
      return someQuery(id).reviews.firstWhere(
        (r) => == reviewId);
  }, middleware: [put, middleware, here]);

The default Router does not give any notification of routes being changed, because there is no inherent stream of URL's for it to listen to. This is good, because a server needs a lot of flexibility with which to handle requests.


main() {
  final router = new Router();
    .get('/hello', () {
    });'/user/:id', (router) {
    router.get('/balance', (id) async {
      final user = await someQuery(id);
      return user.balance;

See the tests for good examples.

In the Browser

Supports both hashed routes and pushState. The BrowserRouter interface exposes a Stream<RoutingResult> onRoute, which can be listened to for changes. It will fire null whenever no route is matched.

angel_route will also automatically intercept <a> elements and redirect them to your routes.

To prevent this for a given anchor, do any of the following:

  • Do not provide an href
  • Provide a download or target attribute on the element
  • Set rel="external"

Route State

main() {
  final router = new BrowserRouter();
  // ..
  router.onRoute.listen((route) {
    if (route == null)
      throw 404;
    else route.state['foo'] = 'bar';

  router.listen(); // Start listening

For applications where you need to access a chain of handlers, consider using onResolve instead. You can see an example in web/shared/basic.dart.

Route Parameters

Routes can have parameters, as seen in the above examples. Use allParams in a RoutingResult to get them as a nice Map:

var router = new Router();
router.get('/book/:id/authors', () => ...);

var result = router.resolve('/book/foo/authors');
var params = result.allParams; // {'id': 'foo'};


  • Minor strong mode updates to work with stricter Dart 2.


  • Patch to work with combinator@1.0.0.

Use this package as a library

1. Depend on it

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

  angel_route: ^2.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:angel_route/angel_route.dart';
Version Uploaded Documentation Archive
2.0.7 Jun 23, 2018 Go to the documentation of angel_route 2.0.7 Download angel_route 2.0.7 archive
2.0.6 Jun 4, 2018 Go to the documentation of angel_route 2.0.6 Download angel_route 2.0.6 archive
2.0.5 Nov 28, 2017 Go to the documentation of angel_route 2.0.5 Download angel_route 2.0.5 archive
2.0.4 Nov 28, 2017 Go to the documentation of angel_route 2.0.4 Download angel_route 2.0.4 archive
2.0.3+2 Nov 28, 2017 Go to the documentation of angel_route 2.0.3+2 Download angel_route 2.0.3+2 archive
2.0.3+1 Nov 27, 2017 Go to the documentation of angel_route 2.0.3+1 Download angel_route 2.0.3+1 archive
2.0.3 Nov 27, 2017 Go to the documentation of angel_route 2.0.3 Download angel_route 2.0.3 archive
2.0.2 Nov 26, 2017 Go to the documentation of angel_route 2.0.2 Download angel_route 2.0.2 archive
2.0.1 Nov 25, 2017 Go to the documentation of angel_route 2.0.1 Download angel_route 2.0.1 archive
2.0.0 Nov 25, 2017 Go to the documentation of angel_route 2.0.0 Download angel_route 2.0.0 archive

All 39 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 Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8


Detected platforms: Flutter, web, other

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


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 angel_route.dart.

Format lib/angel_route.dart.

Run dartfmt to format lib/angel_route.dart.

Format lib/browser.dart.

Run dartfmt to format lib/browser.dart.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/route.dart (Run dartfmt to format lib/src/route.dart.)
  • lib/src/routing_exception.dart (Run dartfmt to format lib/src/routing_exception.dart.)
  • lib/src/routing_result.dart (Run dartfmt to format lib/src/routing_result.dart.)
  • lib/src/symlink_route.dart (Run dartfmt to format lib/src/symlink_route.dart.)
  • lib/string_util.dart (Run dartfmt to format lib/string_util.dart.)


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
combinator ^1.0.0 1.0.0+3
meta ^1.0.0 1.1.6
path ^1.0.0 1.6.2
string_scanner ^1.0.0 1.0.3
Transitive dependencies
charcode 1.1.2
code_buffer 1.0.1
matcher 0.12.4
quiver 2.0.0+1
source_span 1.4.1
stack_trace 1.9.3
tuple 1.0.2
Dev dependencies
browser >=0.10.0 <0.11.0
dart2_constant ^1.0.0
http >=0.11.3 <0.12.0
test >=0.12.15 <0.13.0