shelf_router_generator
1.1.5, released 5 months ago by tools.dart.dev
Generate request routers for the shelf web-framework using source annotations.
What it does
It provides a builder compatible with package:build that automatically generates request routers for the Shelf web framework based on annotations in code. It allows developers to define routes cleanly inside service classes rather than manually wiring handlers together.
AI-written summary of version 1.1.5, based on the package's README and metadata. Report an inaccuracy
Use it when
- Building web applications or servers using the shelf framework
- You prefer annotation-driven route generation over manual configuration
Skip it when
- Not using the shelf web framework
- You prefer manual router configuration without build_runner steps
Strengths
- Keeps routing logic organized inside respective service classes
- Integrates seamlessly with build_runner and source_gen
Weaknesses
- Requires running a build step via build_runner
- Adds code generation boilerplate to the project
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 8
Add shelf_router_generator and build_runner to dev_dependencies, then run build_runner to generate routing code.
class UserService {
@Route.get('/users/')
Future<Response> listUsers(Request request) async {
return Response.ok('["user1"]');
}
Router get router => _$UserServiceRouter(this);
}Alternatives
Packages that do the same job and could replace shelf_router_generator.
- copy_with_extension
Annotation for generating copyWith extensions code using copy_with_extension_gen.
87Compare - build_cli
Parse command line arguments directly into an annotation class using build_runner or a standalone CLI.
82Compare - widgetbook_annotation
Annotations for widgetbook_generator to build Flutter widgets in isolation.
80Compare - masamune
A Flutter framework that uses code generation to scaffold apps with built‑in state, routing, forms and theming.
77Compare
Works with
Packages commonly used together with shelf_router_generator: ones it builds on, ones built on it, and its own family.
- analyzershelf_router_generator depends on itPerforms static analysis of Dart code for tool integration and embedding.
- shelfshelf_router_generator depends on itComposable web server middleware for Dart
- code_buildershelf_router_generator depends on itA fluent, builder-based library for generating valid Dart code programmatically.
- buildshelf_router_generator depends on itPackage for authoring build_runner compatible code generators.
- build_configshelf_router_generator depends on itFormat definition and support for parsing build.yaml configuration.
- source_genshelf_router_generator depends on itSource code generation builders and utilities for the Dart build system.
- http_methodsshelf_router_generator depends on itProvides a list of IANA‑registered HTTP methods and helper functions to check them.
- shelf_routershelf_router_generator depends on itA request router for the shelf web-framework with support for URL parameters and nested routers.