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 [{data: 'This path'}]
findRoute(router, "GET", "/path");
// Returns [{ data: 'named route', params: { name: 'fooval' } }]
findRoute(router, "POST", "/path/fooval");
// Returns [{ data: '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.
Libraries
- routingkit
- Routing Kit - Lightweight and fast router for Dart.