path_tree 2.2.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

path_tree #

PathTree provides a fast data structure to match HTTP URL routes. Also handles regular expression (regexp) and glob path segments.

2.2.1 #

  • Glob path bug fix

2.2.0 #

  • Architecture


import 'package:path_tree/path_tree.dart';

main() {
  final tree = PathTree<int>();

  // Add routes
  tree.addPath('/', 0);
  tree.addPath('/api', 1);
  tree.addPath('/api/book/create', 11);
  tree.addPath('/api/book/:id', 12);
  tree.addPath('/api/book/:id/edit', 13);
  tree.addPath('/api/book/:id/*', 14);
  tree.addPath('/api/user/create', 21);
  tree.addPath('/api/user/:id', 22);
  tree.addPath('/api/user/:id/edit', 23);
  tree.addPath('/api/user/:id/street/:street', 24);

  // Match routes
  print(tree.match(pathToSegments('/'), 'GET'));
  print(tree.match(pathToSegments('api'), 'GET'));
  print(tree.match(pathToSegments('api/book/create'), 'GET'));
  print(tree.match(pathToSegments('api/book/123'), 'GET'));
  print(tree.match(pathToSegments('api/book/123/edit'), 'GET'));
  print(tree.match(pathToSegments('api/book/123/author/123'), 'GET'));
  print(tree.match(pathToSegments('api/user/create'), 'GET'));
  print(tree.match(pathToSegments('api/user/123'), 'GET'));
  print(tree.match(pathToSegments('api/user/123/edit'), 'GET'));
  print(tree.match(pathToSegments('api/user/123/street/123'), 'GET'));

Use this package as a library

1. Depend on it

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

  path_tree: ^2.2.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter 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_tree/path_tree.dart';
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 Apr 4, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/path_tree_base.dart. (-1.49 points)

Analysis of lib/src/path_tree_base.dart reported 3 hints:

line 41 col 29: Use = to separate a named parameter from its default value.

line 47 col 29: Use = to separate a named parameter from its default value.

line 129 col 13: DO use curly braces for all flow control structures.

Maintenance suggestions

Package is getting outdated. (-63.56 points)

The package was last published 85 weeks ago.

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
Dev dependencies
test ^1.3.0