dart_router 0.0.2 copy "dart_router: ^0.0.2" to clipboard
dart_router: ^0.0.2 copied to clipboard

A simple framework for application routing..

DartRouter #

DartRouter is a URL router implemented in dart, that uses a trie data structure to store and match URL patterns. It supports URL parameters and wildcards.

Features #

  • Support parsing URLs with path and query parameters
  • Support wildcard pattern matching for paths
  • Support for adding, searching, and printing all registered routes
  • Type-safe and intuitive API

Usage #

Here's an example of how to use DartRouter in your code:

 final router = Router();
  router.addRoute("app://user/:id", (ctx) {
    print("user id: ${ctx.params["id"]}");
  });
  router.addRoute("app://user/:id/:name", (ctx) {
    print("user id: ${ctx.params["id"]}");
    print("user name: ${ctx.params["name"]}");
  });
  router.addRoute("app://users/*all", (ctx) {
    print("users all: ${ctx.params["all"]}");
  });

  router.handle("app://user/123");
  router.handle("app://user/123/abc");
  router.handle("app://users/123/abc");

Author #

tbxark, tbxark@outlook.com

License #

DartRouter is available under the MIT license. See the LICENSE file for more info.

0
likes
100
pub points
0%
popularity

Publisher

unverified uploader

A simple framework for application routing..

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on dart_router