fiber_router_gen 1.5.0
fiber_router_gen: ^1.5.0 copied to clipboard
Code generator for fiber_router - produces typed BuildContext navigation extensions from your PoppinRouter definition. Run once, navigate anywhere.
Changelog #
1.5.0 #
- Every shell/controller/group node gets a short generated class name by default, derived from its own
name(e.g.storeinstead ofstoreController,paginationinstead of some builder-derived name). When that short class name collides with another node's elsewhere in the tree (e.g. bothstoreandbrandhave a shell named"pagination"), every colliding node is instead qualified with its full ancestor path from the root down to itself (e.g.ContextRouterDashboardStorePagination/ContextRouterDashboardBrandPagination) — this only changes the generated class name, never the getter used to reach it, so call sites stay short (store.pagination...,brand.pagination...). If a collision still can't be resolved this way (e.g. two nodes with the exact same name at the exact same tree position), generation fails with a clear error instead of emitting duplicate classes. - Every
shellalways gets its own generated class now, regardless of how many shells its parentcontrollerhas — the generated class structure mirrors therouter.dartnode tree exactly, with no implicit merging. (An earlier draft of this release auto-merged a controller's sole shell child into the controller's own class; that was reverted for consistency — a controller with one shell no longer behaves differently from one with several.) FiberRouteNode.view()and.deeplink()now accept the new, requirednameparameter (seefiber_router1.3.8) to override the generated getter name.- Controller nodes now expose
Future<R?> go<R>({bool replace})directly on their own class instead of via a nested.controllergetter (context.router.x.go()instead ofcontext.router.x.controller.go()). It's only generated when the controller's first leaf view takes no required parameters — otherwisego()would silently redirect there with missing/null params, so it's omitted instead. - Removed
push()and thenamegetter from the controller's self-navigation block — onlygo()is generated now. - Removed the now-unused
ControllerRouter<T>andControllerRouterParams<T, P>generated helper classes. - Fix: a blank
name: ""is now treated the same as an omitted name. Previously it was taken literally and could produce a duplicate, invalidContextRouterclass with a broken empty-named getter. bin/fiber_router_gen: stopped collecting controller builder widget types for import filtering — they're no longer referenced as types in the generated output, and doing so could produce unused-import warnings (e.g. for the dashboard's builder widget).- Controller nodes now expose
go(params)(instead of nothing) even when the first leaf view they'd redirect to requires params — it forwards straight to that leaf's own generated getter (e.g.detail.go(params)callsdetail.general.go(params)under the hood), so callers no longer need to know or name the first leaf directly. - The literal string passed to
_context.goShellNamed(...)inside a generated controller'sgo()/delegatedgo(params)now matchesfiber_router's new ancestor-path-qualified route name (seefiber_router1.3.8) instead of the controller's barename— required to stay in sync now that the real registered route name is qualified.
1.4.7 #
- All router helpers (
GoRouter,GoRouterParams,ShellRouter,ShellRouterParams,ControllerRouter,ControllerRouterParams) now exposeFuture<R?> go<R>(...)instead ofvoid go(...)— callers can await the result returned bycontext.pop(result)on the pushed route. _onNavigatefunction types updated fromvoid Function(...)toFuture<dynamic> Function(...)to propagate the push result through the lambda.ShellRouter<T>no longer stores_onNavigate—go<R>()andpush<R>()both delegate directly to_context.goShellNamed<R>(name, replace: ...). Generated shell getters simplified toShellRouter<T>(_context, 'route_name').
1.4.6 #
ShellRouter<T>now storesBuildContext _contextand exposesFuture<R?> push<R>()— calls_context.goShellNamed<R>(name, replace: false), returning the value passed tocontext.pop(result)by the pushed route.- Generated shell getters pass
_contextas the first constructor argument:ShellRouter<T>(_context, (r) => ...).
1.4.5 #
ShellRouter<T>now takesvoid Function(bool)and exposesgo({bool replace = true})— defaults to replace to preserve existing shell behavior.ShellRouterParamsupdated similarly.- Generated shell getters pass
(r) => _context.goShell<T, P>(replace: r).
1.4.4 #
ControllerRouter<T>now takesvoid Function(bool)and exposesgo({bool replace = false})— matches theGoRouterAPI, allows push or replace navigation.ControllerRouterParamsupdated similarly.- Generated
controllergetter passes(r) => _context.goShellNamed(routeName, replace: r)toControllerRouter.ShellRouteris unchanged.
1.4.3 #
- Fix controller builder type fallback:
_parseControllerNodenow defaults to'ControllerView'instead of'Controller'when nobuilderargument is present, producingControllerRouter<ControllerView>in the generated output.
1.4.2 #
- Fix controller navigation when an explicit
nameis provided: generatedControllerRouternow calls_context.goShellNamed(routeName)instead of_context.goShell<T, Null>(), so the correct registered route name is used rather than the builder widget type snake-cased fromT.toString().
1.4.1 #
- Fix missing import for controller builder widget types (e.g.
DashboardView):_allControllerBuilderTypesnow collects builder widget types from allRouterControllerNodeinstances and adds them toneededTypes, so their import files are emitted in the generated output.
1.4.0 #
- Add
FiberRouterBase<T>— abstract base class with a singlenamefield, shared by all router helper types. GoRouter,GoRouterParams,ShellRouter,ShellRouterParamsnow extendFiberRouterBase<T>viasuper.name.- Add
ControllerRouter<T>andControllerRouterParams<T, P>— generated forcontrollerroute nodes.ControllerRouter.go()navigates to the controller entry point viagoShell. - Controller context classes (e.g.
ContextRouterDashboard) now expose aControllerRouter<T> get controllergetter and aString get namealongside their children getters. - Fix import filter: exclude
.g.dartfiles (prevents self-import on re-generation), remove_fileReexportsPackagesheuristic, replace with recursive_fileContainsBuildContextExtensionthat follows both relative andpackage:exports — correctly includesui(re-exportsfiber_router→on BuildContext) while excluding unrelated packages likeservices. - Fix
_allViewNodesin the generator binary to traverseRouterControllerNodechildren, ensuring view types inside controllers are included inneededTypesand their import files are emitted.
1.3.0 #
- Add support for
FiberRouteNode.controller()— parsed and generated identically to shell nodes, producing a namedContextRouter{Name}class withisShell: truechildren. - Add optional
nameargument parsing for bothshellandcontroller— when provided, it overrides the group class name derived from the builder widget type. - Remove
_shellGroupNamehelper — replaced byeffectiveGroupNamegetter onRouterShellNodeandRouterControllerNode.
1.2.1 #
ShellRouterandShellRouterParamsare now emitted directly in the generated file (alongsideGoRouter/GoRouterParams), rather than being imported fromfiber_router.
1.2.0 #
- Shell view getters now generate
ShellRouter/ShellRouterParams(fromfiber_router) instead ofGoRouter/GoRouterParams. - Shell navigation calls
goShell(goNamed) instead ofgo(pushNamed) — navigating within a shell swaps the child without stacking. - Fix:
_writeGroupClassesnow passesisShell: truewhen writing the class for aRouterShellNode, so the correct types are emitted for all shell children.
1.1.1 #
- Fix shell widget type extraction:
AuthView(child: child)is parsed as aMethodInvocationwithout a target — now correctly returnsmethodName.nameinstead of falling back to'Shell'.
1.1.0 #
- Shell nodes now generate a named
ContextRouter{Name}class instead of inlining children into the parent. The class name is derived from the builder widget type:AuthView→ContextRouterAuth, accessible viacontext.router.auth. - Parser extracts the shell widget type from the builder expression AST (
(ctx, child) => AuthView(...)→AuthView). - Generator derives the group name by stripping the
Viewsuffix from the builder type.
1.0.0 #
- Initial release.
- Parses
@FiberRouterGen()-annotatedFiberRouter.create()declarations. - Generates typed
BuildContextextension withContextRouterand nested group classes. - Supports
FiberRouteNode.view(),.node(),.shell(), and.deeplink(). - Generates
Parametersclasses withtoQuery()/fromMap()for deeplink routes. - Shell routes are transparent — their children are exposed directly on the parent class.
- Filters imports automatically — only includes what the generated file needs.