zenrouter_file_generator 3.0.0 copy "zenrouter_file_generator: ^3.0.0" to clipboard
zenrouter_file_generator: ^3.0.0 copied to clipboard

A code generator for file-based routing in Flutter and DartNative using ZenRouter.

3.0.0 #

Stable file-based routing generator for Flutter and DartNative. The changes below cover the 3.0 beta APIs and native generation introduced before stable.

Breaking changes #

  • Generated coordinators expose RouteManifest<String> topology and mix in RouteModuleBinding; URI dispatch uses RouteBinding and RouteBinding.deferred instead of a generated parseRouteFromUri switch.
  • Reverse routing moves from {route}Location() methods to the typed coordinator.location.{route} namespace, including parameterized helpers such as location.profileId(...).
  • Fixed indexed/branched children are encoded on sealed RouteManifestLayoutKind.indexed([...]) / .branched([...]) values; stack layouts use .stack(). Regenerate checked-in output to adopt this topology.
  • Generated APIs require the 3.0.0 core and annotation packages. Regenerate route parts and the aggregate coordinator together when upgrading.

Added #

  • Generate static Coordinator.manifest topology, validated runtime bindings, and absolute reverse-routing locations from the same route tree.
  • Generate BranchedStackPath fields, branched manifests, and typed layout base classes from @ZenLayout(type: LayoutType.branched, branches: ...).
  • Forward all destination operations through NavContext: push, pushSilently, navigate, replace, pushReplacement, pushOrMoveToTop, and recover. pop and tryPop remain coordinator operations.
  • Add platform: dartnative to both zen_route and zen_coordinator builder options. The default remains platform: flutter; unsupported values fail configuration with an ArgumentError.
  • Generate native route bases, coordinators, route bindings, location helpers, navigation extensions, and stack/indexed/branched logical layouts using zenrouter_dartnative: ^0.1.0 and DartNative widgets.
  • Native file routing supports dynamic parameters, catch-all parameters, route groups, and a root initial route. The example includes the main_file_router.dart entry point.

Changed #

  • Remove the runtime Flutter SDK dependency and Flutter environment constraint so native apps can consume the generator without depending on Flutter.
  • Keep RouteManifest<String> explicit in generated code; handwritten coordinators can still use enum or domain IDs.
  • Generated not-found routes implement RouteNotFound and preserve the requested URI for typed 404 resolution.

Fixed #

  • Reject duplicate and equally-specific ambiguous route patterns during generation instead of deferring ambiguity to navigation time.
  • Generate absolute dynamic route URIs with independently encoded path segments, preserving reserved characters and catch-all parameter structure.

DartNative limitations #

  • Native generation rejects deferred imports, generated @ZenRoute query helpers, and Flutter transition mixins with generation errors.
  • Configure native transitions through the route's presentation; handle URI queries in the route when needed.
  • The adapter's restoration and physical native stack limits still apply; generated branched layouts do not create independent native Navigator hosts.

Requirements #

  • Dart 3.11 or newer; zenrouter_core: ^3.0.0 and zenrouter_file_annotation: ^3.0.0.
  • Native apps resolve the framework with dn pub get and run build tools with the Dart executable from the same DartNative SDK.

3.0.0-beta.1 #

Prerelease for early testers. Requires zenrouter_core and zenrouter_file_annotation ^3.0.0-beta.1. APIs may still change before 3.0.0.

  • Generate BranchedStackPath fields, branched manifest topology, and typed layout base classes from @ZenLayout(type: LayoutType.branched, branches: ...).
  • Emit sealed RouteManifestLayoutKind.stack() / .indexed([...]) / .branched([...]) values so generated manifests keep fixed children on the kind.
  • Generate Coordinator.manifest as the static route topology used by RouteModuleBinding and generated RouteBinding adapters.
  • Mix RouteModuleBinding into the generated coordinator and emit RouteBinding / RouteBinding.deferred instead of a parseRouteFromUri switch.
  • Emit RouteManifest<String> explicitly while handwritten coordinators may use enum or domain ID types.
  • Generate AppCoordinator.location.{route} reverse-routing helpers (location.home, location.profileId(...)) instead of {route}Location().
  • NavContext now forwards every destination operation (push, pushSilently, navigate, replace, pushReplacement, pushOrMoveToTop, recover). pop / tryPop stay on the coordinator.
  • Reject duplicate and equally-specific ambiguous route patterns during code generation.
  • Generated not-found routes preserve the requested URI and implement RouteNotFound, allowing core resolution and SSR adapters to retain HTTP 404 semantics.
  • Generated dynamic route URIs are absolute and encode each path segment independently.

1.1.3 #

  • Chore: Bump analyzer: ^12.0.0, build: ^4.0.6, source_gen: ^4.2.3, dart_style: ^3.1.8

1.1.2 #

  • Chore: Clean up code style

1.1.1 #

  • Fix: Require zenrouter_file_annotation: ^1.0.1 so PathParser.parseDirParts is always available.

1.1.0 #

  • Fix: dot-notation failed to resolve layout

1.0.0 #

  • BREAKING: Requires zenrouter: ^1.0.0 and zenrouter_file_annotation: ^1.0.0
  • Stable release: Production-ready file-based routing generator
  • Generates code compatible with zenrouter 1.0.0 features

0.4.14 #

  • Fix: Upgrade to analyzer to ^9.0.0

0.4.13 #

  • Docs: Add "Customizing the Coordinator" section to README
  • Docs: Add Table of Contents to README

0.4.12 #

  • Feat: Add super.paths to ensure root always added in the paths getter (Thanks @mrgnhnt96)

0.4.11 #

New Features #

  • NavContext extension: Auto-generated extension on route base class (e.g., AppRoute) providing convenient navigation methods directly from route instances:
    • route.navigate(context) - Navigate to the route
    • route.push<T>(context) - Push the route and optionally return a result
    • route.replace(context) - Replace the current route
    • route.recover(context) - Recover to the route

0.4.10 #

New Features #

  • CoordinatorProvider: Auto-generated InheritedWidget provider for accessing the coordinator from the widget tree via context.appCoordinator
  • layoutBuilder override: The generated Coordinator now includes a layoutBuilder override that wraps layouts with the provider
  • deferredImport in @ZenCoordinator: Configure global deferred import via annotation, overriding build.yaml
  • routeBasePath in @ZenCoordinator: Import a custom base route class from a specified path instead of generating it
  • outputFile config: New build.yaml option to customize the output filename (default: routes.zen.dart)

Bug Fixes #

  • Fixed file processing order: Read _coordinator.dart directly first before processing routes to ensure correct configuration

0.4.9 #

  • Refactor: Use shared code generation utilities (LayoutCodeGenerator, RouteCodeGenerator) from zenrouter_file_annotation

0.4.8 #

  • Docs: Update README

0.4.7 #

  • Docs: Update README and add screenshots

0.4.6 #

  • Downgrade analyzer to ^8.0.0 for compatibility.

0.4.5 #

  • Support new RouteQueryParameters and new dot notation flavor in naming convention.

0.4.1 #

  • Docs: Improve documentation and update outdated examples
  • Bump zenrouter_file_annotation to 0.4.0

0.4.0 #

  • BREAKING CHANGE: Upgraded generated code to use zenrouter 0.4.0+ constructor syntax (NavigationPath.createWith/IndexedStackPath.createWith). Requires zenrouter: ^0.4.0.

0.3.1 #

  • NEW FEATURE: Add ability to lazy load routes using the deferredImport option in the @ZenCoordinator annotation
  • PERFORMANCE IMPROVEMENTS: Performance improvements (30-40% faster generation, 25-35% lower memory) and automatic code formatting with dart_style

0.3.0 #

  • Bump version to 0.3.0
  • Add support for catch-all parameters ([...slugs], [...ids], etc) in routes, including List<String> type handling and updated route specificity sorting.

0.2.3 #

  • Format files

0.2.2 #

Bug Fixes #

  • Update the debug label correctly for the generated Path in the Coordinator
  • Update README.md

0.2.1 #

New Features #

  • Extract annotations and analyzer elements into a new zenrouter_file_annotation package

Breaking Changes #

  • Remove zenrouter_file_generator from pubspec.yaml and move it to dev_dependencies

0.2.0 #

New Features #

  • Route Groups (name): Wrap routes in a layout without adding the folder name to the URL path
    • Folders named with parentheses like (auth) create route groups
    • Routes inside (auth)/login.dart generate URL /login (not /(auth)/login)
    • Routes are still wrapped by the _layout.dart in that folder
    • Useful for grouping auth flows, marketing pages, or applying shared styling

0.1.0 #

  • Initial release of zenrouter_file_generator with file-based routing support for Flutter.
8
likes
140
points
469
downloads

Documentation

API reference

Publisher

verified publisherzennn.dev

Weekly Downloads

A code generator for file-based routing in Flutter and DartNative using ZenRouter.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

analyzer, build, dart_style, glob, source_gen, zenrouter_core, zenrouter_file_annotation

More

Packages that depend on zenrouter_file_generator