router_builder 4.0.0
router_builder: ^4.0.0 copied to clipboard
Typed route definitions, navigation policies, and deep-link matching for Flutter apps using router_builder_generator.
CHANGELOG #
4.0.0 #
- Breaking. The code generator moved to
router_builder_generator. Applications that regenerate routes must addrouter_builder_generator: ^4.0.0todev_dependencies. Annotations, runtime models, and generated route helpers retain their public names. - The runtime depends on Flutter,
dart_helper_utilsandequatable. Apps and libraries can now use existing generated routes without resolving the analyzer and build toolchain through the runtime. - Custom builders use
router_builder_generator:generate_route_info_helperin build configuration andpackage:router_builder_generator/builder.dartin Dart. After adding the generator, previewdart run router_builder_generator:migrate_builder_importsand add--writeto apply. Run it before other bulk fixes to preserve prefixes, conditional imports and references to same-named classes. The generator requires Dart 3.11 or later and supports analyzer 13.x and 14.x. Migration guide - The runtime accepts
dart_helper_utils6.0.1 through 7.x andequatable2.0.8 through 3.x. The helper minimum providesfirstWhereOrNullfor generated route lookups. The runtime now declares Dart 3.10 as its minimum, matching the SDK already required by its dependencies. Apps on Dart 3.10 through 3.13.4 can resolve compatible 6.x helpers.
3.1.0 #
-
Added
RouteInfo.location()andRouteInfo.locationForArgs(): the supported way to build a location string to hand to the router. Both are derived from the samegeneratePath()the route tree is registered with, so a location can no longer point at a path the tree does not register.Apps that built locations by hand (for example
'/$branchName/${route.name}') should calllocation(parentRoute: branch)instead. Hand-rolled string concatenation is the failure this release closes: registration and navigation were two independent implementations of one rule, and editing either one silently desynced navigation from the tree.location()also fixes two defects such call sites commonly had: the parent segment is taken from the parent'sgeneratePath()rather than itsname, so a branch with a custompathnests correctly; and path parameters are hydrated frompathParams/idand percent-encoded. -
Clarified in the
generatePath()docs that a nested route is registered under itsname, not itspath. The nested segment identifies the route inside the tree, so it stays stable when the public URL inpathchanges; the two are allowed to differ, anddeepLinkNamescarries the public-URL job. -
A missing path parameter now trips an assert in debug and returns the unfilled template in release, so the router surfaces its error page instead of the caller throwing inside a tap handler.
-
No breaking changes:
generatePath(),generateName()and the registered tree are unchanged.
3.0.2 #
- Added installable AI coding-assistant support for Claude Code and OpenAI
Codex, distributed from the GitHub repository (marketplace
router-builder-plugins, pluginrouter-builder): eight package-specific skills (setup, add-route, route-policy / deep-link / generation debugging, route audits, the v2 -> v3 migration with the bundled codemod, and a version upgrade orchestrator) plus a read-onlyroute-auditorsubagent for Claude Code. See "AI coding-assistant support" in the README. No runtime API or dependency changes; the plugin tree is excluded from the pub.dev archive. - Docs: generator commands updated for current build_runner, which removed
the
--delete-conflicting-outputsflag (older build_runner versions still accept it).
3.0.1 #
- Relaxed the
analyzerconstraint to allow compatible 12.x releases.
3.0.0 #
Major release. See MIGRATION_GUIDE.md for the full v2 -> v3
guide. Run tool/migrate_to_v3.sh (dry-run by default; --write to apply) to
make the mechanical edits - removing isIdSlug, MyRoutes -> Routes,
RouteInfoHelper -> RoutesHelper, and collapsing deep imports to the barrel.
Breaking #
RoutePolicyis now the single home for cascading behavior (9 fields). Flat behavioral params/getters onRouteInfoandRouteArgsare removed; set them viapolicy:and read them via the resolved getters.isGlobalOnlyrenamed topushGloballyeverywhere.RouteArgshas one constructor (the private clone is gone);isIdSlugis removed (detect slug-vs-id from the value at the gate).- Package layout moved under
lib/src/; import onlypackage:router_builder/router_builder.dart. Deep imports (package:router_builder/models/...) andmodels/models.dartare gone. build.yamlmust importpackage:router_builder/builder.dart.- Generated output defaults to
lib/routes.g.dartwith classesRoutesandRoutesHelper(waslib/route_info_helper.dart,MyRoutes,RouteInfoHelper). Override via builder options if you prefer the old names. - Deep-link host matching is now exact-or-suffix (was substring); verify your allowed-hosts list.
- Deep-link key conflicts now fail the build by default (
fail_on_conflict). - Builder typedefs unified to
(BuildContext, RouteArgs?). RouterBuilderConfig.defaultsis read-only; usesetDefaults(RoutePolicy).
Added #
RoutePolicy.merge/copyWith/reportandglobal/public/popuppresets.RouterBuilderConfigcomplete defaults,reset,isConfigured,markConfigured.- Same-named resolved getters on
RouteInfo;effectiveXgetters onRouteArgs; branch/redirect structural constraints (force + debug assert). - Runtime-derived generated categories (
normalRoutes,globalRoutes,popupRoutes,topLevelRoutes,authorizedRoutes,redirectRoutes) that cannot drift from installed defaults;allRoutesnow includes redirect-only routes. - Configurable generator (
output,route_class_name,helper_class_name,fail_on_conflict);@RTdiscovery now includes top-level consts/finals. @RTConfigannotation + generatedRoutesHelper.installDefaults().deepLinkPushGloballypolicy field (default true); deep-link push-global is now policy-driven.- JSON-safe
report()onRoutePolicy/RouteInfo/RouteArgs. - First test suite and a runnable
example/.
2.0.4 #
- Relaxed
dart_helper_utilsconstraint to allow compatible 6.x releases.
2.0.3 #
- Relaxed
analyzeranddart_styleconstraints so consumers can resolve with analyzer 9 or analyzer 10.
2.0.2 #
- Updated all packages to the latest version and migrated to the latest analyzer and build runner.
2.0.0 #
- Updated all packages to the latest version and migrated to the latest analyzer and build runner.
1.2.0 - 2026-01-20 #
🚀 Major Feature: Policy-Driven Routing #
This release introduces a robust, hierarchical configuration system for route behaviors, allowing precise control over authorization, duplication, and global navigation settings.
Added
- RoutePolicy: Centralized policy object for
mustBeAuthorized,duplicateBehavior,pushGlobally, andisPopupRoute. - Global Defaults: New
RouterBuilderConfigto set app-wide default policies. - Duplicate Route Control: Added
DuplicateRouteBehaviortoRouteInfoandRouteArgs. - Precedence Logic:
RouteArgsnow resolves policies in a clear order:- Args Override
- Args Policy
- Route Definition Override
- Route Definition Policy
- Global Defaults
Updated
- RouteInfo: Added
duplicateBehaviorandpolicyfields. - RouteArgs: Added override fields (
duplicateBehavior,mustBeAuthorized,policy) and logic to compute effective values. - Code Generator: Updated to support
duplicateBehaviorin@RTannotations.
1.1.2 - 2025-11-07 #
- Renamed
replaceAlltoshouldReplaceAll.
1.1.1 - 2025-10-24 #
- Documented all public APIs.
1.0.0 - 2025-01-24 #
🚀 Major Enhancement: Unified Deep Link System #
Added
- DeepLinkHandler: New generic abstract class for type-safe deep link handling
- Enhanced RouteInfo: Added
deepLinkHandlerparameter to all RouteInfo constructors - Comprehensive Deep Link Map: Generated map now includes:
- Route names as keys
- First path segments as keys
- Deep link aliases from
deepLinkNames - Build-time conflict detection with detailed error messages
- Migration Guide: Comprehensive guide for migrating from separate deep link registries
- Updated Documentation: Enhanced AI docs with deep link examples and patterns
Changed
- Code Generator: Enhanced to extract path parameters and create comprehensive key mappings
- Deep Link Resolution: Routes are now the single source of truth for deep links
- Generated Helper:
deepLinkMapis now suitable for complete URI resolution
Benefits
- ✅ Single source of truth for routes and deep links
- ✅ No more RegExp patterns or manual handler registration
- ✅ Build-time validation of deep link conflicts
- ✅ Co-located deep link logic with route definitions
- ✅ Reduced boilerplate code
- ✅ Type-safe deep link handling
0.0.1 Initial Release #
- INITIAL: Initial release with basic route generation