Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/medz/routingkit
🛸 Routing Kit - Lightweight and fast router for Dart.
https://github.com/medz/routingkit
dart flutter router routing routing-kit
Last synced: about 2 months ago
JSON representation
🛸 Routing Kit - Lightweight and fast router for Dart.
- Host: GitHub
- URL: https://github.com/medz/routingkit
- Owner: medz
- License: mit
- Created: 2023-12-14T10:39:15.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-30T04:01:46.000Z (3 months ago)
- Last Synced: 2024-10-12T02:49:28.656Z (2 months ago)
- Topics: dart, flutter, router, routing, routing-kit
- Language: Dart
- Homepage:
- Size: 107 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
RoutingKit
Routing Kit - Lightweight and fast router for Dart.## Installation
Run this command:
```bash
dart pub add routingkit
```With Flutter:
```bash
flutter pub add routingkit
```## Usage
### Create a router instance and insert routes
```dart
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
```dart
// {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](https://github.com/medz/routingkit?tab=MIT-1-ov-file).