routingkit 3.0.0 copy "routingkit: ^3.0.0" to clipboard
routingkit: ^3.0.0 copied to clipboard

Routing Kit - Lightweight and fast router. - A composable pure function routing kit.

RoutingKit

Pub Version Test License Sponsors X (formerly Twitter) Follow

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();

router.add('get', '/path', 'Static path');
router.add('get', '/path/:name', 'Param route');
router.add('get', '/path/*', 'Unnamed param route');
router.add('get', '/path/**', 'Wildcard Route');
router.add('get', '/path/**:rset', 'Named wildcard route');
router.add('get', '/files/:dir/:filename.:format,v:version', 'Mixed Route');

Match route to access matched data #

// {data: Static path}
print(router.find('get', '/path')?.toMap());

// {data: Param route, params: {name: seven}}
print(router.find('get', '/path/seven')?.toMap());

// {data: Wildcard Route, params: {_: foo/bar/baz}}
print(router.find('get', '/path/foo/bar/baz')?.toMap());

// {data: Mixed Route, params: {dir: dart, filename: pubspec, format: yaml, version: 1}}
print(router.find('get', '/files/dart/pubspec.yaml,v1')?.toMap());

// `null`, No match.
print(router.find('get', '/'));

License #

RoutingKit is open-sourced software licensed under the MIT license.

3
likes
0
pub points
26%
popularity

Publisher

verified publisherodroe.dev

Routing Kit - Lightweight and fast router. - A composable pure function routing kit.

Repository (GitHub)
View/report issues

Topics

#router #routing #route #fast-router #routing-kit

Funding

Consider supporting this project:

github.com

License

unknown (license)

More

Packages that depend on routingkit