routingkit 2.0.0 routingkit: ^2.0.0 copied to clipboard
Routing Kit - Lightweight and fast router for Dart.
RoutingKit
Routing Kit - Lightweight and fast router for Dart.
Installation #
Run this command:
dart pub add routingkit
With Flutter:
flutter pub add routingkit
Usage #
Create a router instance and insert routes #
import from "routingkit";
const router = createRouter();
addRoute(router, "GET", "/path", 'this path');
addRoute(router, "POST", "/path/:name", 'named route');
addRoute(router, "GET", "/path/foo/**", 'wildcard route');
addRoute(router, "GET", "/path/foo/**:name", 'named wildcard route');
Match route to access matched data #
// Returns [{ payload: 'this path' }]
findRoute(router, "GET", "/path");
// Returns [{ payload: 'named route', params: { name: 'fooval' } }]
findRoute(router, "POST", "/path/fooval");
// Returns [{ payload: 'wildcard route' }]
findRoute(router, "GET", "/path/foo/bar/baz");
// Returns undefined (no route matched for/)
findRoute(router, "GET", "/");
License #
RoutingKit is open-sourced software licensed under the MIT license.