routes 0.1.4

  • Installing
  • Versions
  • 52

##ROUTES 0.1.3

Is a simple server routing via a single routes.dart file

routes builds on route and params package route and params

  1. add dependencies to pubspec

    route: "^0.4.6"
    routes: "^0.1.4"
  2. create a routes file ###ROUTES

inside projectRootFolder/routes.dart

   part of sampleServerGui;
   final Map serverRoutes={
     'byeJs':{'url':new UrlPattern(r'/byeJs'),'action': byeJs,'async':true },
     'helloDart':{'url':new UrlPattern(r'/helloDart'),'method':'GET','action': helloDart }

here we see 2 routes 'byeJs' and 'helloDart'

routes always have a

url -> url pattern and an

action -> called method and an optional

method -> that currently handels 'PUT' and 'GET'

  1. create the simple server with functions for each specified action (helloDart,byeJs) ###SERVER


   library sampleServerGui;
   import "dart:io";
   import 'dart:convert';
   import 'package:route/url_pattern.dart';
   import 'package:routes/server.dart';
   part '../routes.dart';
   final String HOST = ""; // eg: localhost
   final num PORT = 8079;
   main() async {
       var server = await HttpServer.bind(HOST, PORT);
       var router = initRouter(server, serverRoutes);
       print("Listening for GET and POST on http://$HOST:$PORT");
   void printError(error) => print(error);
   helloDart(Map params, HttpResponse res){
     Map newMap = {"language":params["language"]};
     if(params["language"] == "Dart"){

   byeJs(Map params, HttpResponse res){
     //do stuff

now you can talk to the server eg with


the Magic happens here

  var router = initRouter(server, serverRoutes);

it automatically generates a router that will use the specified routes in routes.dart

the action specified inside the routes will recieve 2 parameters

**a Map params **-> including the parameters send in the request **a HTTPResponse res **

Download a working example here


0.1.3 -added
0.1.2 -remove filter again for now
0.1.1 -fix readme
      -added filter for router
0.1.0 -removed rootPath parameter from InitRouter() function
      -added and
0.0.1 -initial commit supports server routing

Use this package as a library

1. Depend on it

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

  routes: ^0.1.4

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:routes/client.dart';
import 'package:routes/server.dart';
Version Uploaded Documentation Archive
0.1.4 May 11, 2016 Go to the documentation of routes 0.1.4 Download routes 0.1.4 archive
0.1.3 Aug 13, 2014 Go to the documentation of routes 0.1.3 Download routes 0.1.3 archive
0.1.2 Aug 13, 2014 Go to the documentation of routes 0.1.2 Download routes 0.1.2 archive
0.1.1 Aug 13, 2014 Go to the documentation of routes 0.1.1 Download routes 0.1.1 archive
0.1.0 Aug 13, 2014 Go to the documentation of routes 0.1.0 Download routes 0.1.0 archive
0.0.1 Aug 12, 2014 Go to the documentation of routes 0.0.1 Download routes 0.0.1 archive
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 Jul 20, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.69.0
  • pana: 0.11.7


Detected platforms: web

Platform components identified in package: html, io, mirrors.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Package is too old.

The package was released more than two years ago.

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 of the 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 routes.dart.

Fix lib/client.dart.

Analysis of lib/client.dart reported 3 hints:

line 4 col 8: Unused import: 'package:params/client.dart'.

line 7 col 8: The value of the local variable 'urls' isn't used.

line 12 col 10: The value of the local variable 'level' isn't used.

Fix lib/server.dart.

Analysis of lib/server.dart reported 2 hints:

line 35 col 16: The value of the local variable 'path' isn't used.

line 65 col 31: 'NOT_FOUND' is deprecated and shouldn't be used.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.4.0 <2.0.0
params >=0.0.3 <0.1.0 0.0.4
route >=0.4.6 <0.5.0 0.4.6
route_hierarchical >=0.4.22 <1.0.0 0.7.0
Transitive dependencies
browser 0.10.0+3
logging 0.11.3+2