path_tree 2.2.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 45

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 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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
1
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
77
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21

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.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. (-18.36 points)

The package was last published 61 weeks ago.

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