Lightweight, fast router for Dart with static, parameterized, and wildcard path matching.
dart pub add rouxWith Flutter:
flutter pub add rouximport 'package:roux/roux.dart';
final router = Router<String>(
routes: {
'/': 'root',
'/users/all': 'users-all',
'/users/:id': 'users-id',
'/users/*': 'users-wildcard',
'/*': 'global-fallback',
},
);
final match = router.match('/users/123');
print(match?.data); // users-id
print(match?.params); // {id: 123}- Static:
/users - Named param:
/users/:id - Wildcard tail:
/users/* - Global fallback:
/*
Notes:
- Paths must start with
/. *is only allowed as the final segment.- Embedded syntax like
/files/:name.:extis intentionally unsupported. - Matching is case-sensitive.
- Trailing slash on input is ignored (
/usersequals/users/). - You can register routes via constructor (
Router(routes: {...})) or incrementally (add/addAll).
- Exact route (
/users/all) - Parameter route (
/users/:id) - Wildcard route (
/users/*) - Global fallback (
/*)
Relic-style comparison benchmark:
dart run bench/relic_compare.dart 500Lookup scenario matrix benchmark:
dart run bench/compare.dart 500MIT. See LICENSE.