path_tree 2.2.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 63

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

example/path_tree_example.dart

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:


dependencies:
  path_tree: ^2.2.2

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:path_tree/path_tree.dart';
  
Version Uploaded Documentation Archive
2.2.2 Aug 15, 2018 Go to the documentation of path_tree 2.2.2 Download path_tree 2.2.2 archive
2.2.1 Aug 15, 2018 Go to the documentation of path_tree 2.2.1 Download path_tree 2.2.1 archive
2.2.0 Aug 14, 2018 Go to the documentation of path_tree 2.2.0 Download path_tree 2.2.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
30
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Mar 6, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

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

Analysis of lib/src/path_tree_base.dart reported 2 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.

Maintenance suggestions

Homepage URL is insecure. (-5 points)

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

Dependencies

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