routingkit 4.1.0 copy "routingkit: ^4.1.0" to clipboard
routingkit: ^4.1.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 "routingkit";

const router = createRouter();

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

Match route to access matched data #

// {data: Static path}
findRoute(router, 'get', '/path')

// {data: Param route, params: {name: seven}}
findRoute(router, 'get', '/path/seven')

// {data: Wildcard Route, params: {_: foo/bar/baz}}
findRoute(router, 'get', '/path/foo/bar/baz')

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

// `null`, No match.
findRoute(router, 'get', '/')

License #

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

3
likes
160
points
269
downloads

Publisher

verified publisherodroe.dev

Weekly Downloads

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

Documentation

API reference

Funding

Consider supporting this project:

github.com

License

MIT (license)

More

Packages that depend on routingkit