auto_go_route 2.0.0
auto_go_route: ^2.0.0 copied to clipboard
Type-safe, code-generated routing for Flutter. Full go_router feature parity with typed path and query parameters, shells, guards and transitions.
2.0.0 #
A breaking release. See MIGRATION.md for a step-by-step guide; most apps need a dependency bump, one annotation rename and typed navigation arguments.
Fixed #
- The build no longer hangs or dies on modern Dart. The generator pinned
analyzer: ^7.0.0, whose supported language version is 3.9.0, so on Dart 3.10+ it failed withMissing implementation of visitDotShorthandPropertyAccess. The analyzer constraint is now>=8.2.0 <15.0.0, and a regression test builds a fixture using post-3.9 syntax (#3). - A
parent:cycle is reported instead of hanging. The parent chain was walked with no visited set, so a widget naming itself — or any two naming each other — spun forever inside the build step. context.pushNamed(...)compiles again. A 1.x extension member collided with go_router's, making every call site that imported both packages fail withambiguous_extension_member_access. The method also recursed into itself. Removed.- Optional path parameters no longer produce unreachable routes.
:id?registered the literal pattern/search/:$1; it is now a build error naming the two things that do work. - Parameter values are no longer corrupted or fabricated. A parameter name
that prefixed another (
:idand:idCard) silently produced/user/5/card/5Card; the required-parameter regex backtracked, so every optional parameter also generated a truncated phantom sibling; andgetParam<int>returned0for a missing value whilegetParam<int?>threw for a present one. - A shell's
initialRouteis honoured on every shell, not only the root one, and a stateful shell's branches now receive aninitialLocation— a nested shell as a branch previously landed outside itself. - The root shell is no longer emitted twice. Removal matched a string in
the generated source that only the stateful branch produced, so a plain or
pageBuilderroot shell was duplicated and go_router rejected the result. - Generated output is deterministic. Asset discovery order is unspecified and sibling sorting was not total, so match precedence and stateful-shell branch indices could permute between builds.
- A resolution failure is fatal. Errors during discovery went to
log.info, below default verbosity, so the build "succeeded" with routes missing. toBoolOrNullreturnsnullfor unrecognised input;?admin=noread astrue.RouteRegistry.generateGoRoutes(globalRedirect:)composes rather than overwritesGoRoute.redirect, which had been silently deleting every route's guard;validate()accepts the shapes the generator emits; andGoRoute.copyWithforwards all ten fields instead of dropping five.@AutoGoRoute(caseSensitive:)is nowbool?and overrides the router-wide default; the two were ANDed, so a route could not opt back in.RoutePaths.propsexcludes thebuilderclosure, so two instances of a route are equal and hash stably.currentRouteNamereturns a route's name rather than its matched location, which had madeisOnNamedRoutealways false.popUntilRoutecompared a URL against a template and popped the whole stack;popUntilLocationcompares matched locations and is bounded.RouteUtils.isValidPathaccepted no parameterised path at all;sanitizePathlower-cased, changing which route a URL matches under go_router 15+.AdaptiveOverlayPageseparatesbackgroundColorfrombarrierColor, honours its configuration on the dialog branch, closes over its child instead of castingModalRoute.of(context)!.settings, and takes abreakpoint.- Route names are validated as Dart identifiers and for uniqueness after
capitalisation; descriptions are escaped; duplicated path parameters,
metadatavalues that cannot be re-emitted, and conflicting error handlers are all build errors now. - Every function, key and constant an annotation names by string is resolved
against the router library at build time, so a typo is reported at the
annotation rather than as
Undefined nameinside the generated file. - Removed
documentation:frompubspec.yaml, which pointed at an unrelated package, and thebuild_runner/generatordev_dependencies, which this package does not use and which put the lowest supported Flutter out of reach ofpub get. currentLocation,currentRouteName,currentRouteTemplate,isOnRouteandpopUntilLocationfollow imperative pushes to the visible route instead of reporting the one underneath.- A stateful shell's
metadatareaches its children.StatefulShellRoute'sindexedStackconstructor has nometadataparameter, so it was dropped; shells now use the general constructor with an equivalent layout, exposed asShellRoutePaths.indexedStackContainerBuilder. - Animated pages and
AdaptiveOverlayPageno longer crash outside aMaterialAppwhen a dismissible barrier needs a label. RouteUtils.normalizePathno longer drops the first segment of a location starting//;isValidTemplateaccepts regex constraints containing?or#;GoRoute.copyWithaccepts go_router's ownExitCallback;getParam<dynamic>returns the raw string instead of throwing.
Added #
- Typed path and query parameters end to end.
String,int,double,num,bool,BigInt,DateTime,Uriand enums, nullable or not, plusList<T>for repeated query keys. Backed by the new publicRouteCodec. @PathParam,@QueryParam,@RouteExtra,@RouteIgnoreto override classification or rename a wire parameter. Markers are read from the backing field as well as the constructor parameter.- Full go_router parity. New on
@AutoGoRoute:redirect,onExit,parentNavigatorKey,caseSensitive,metadata,pageBuilder,transition,transitionDurationMs,reverseTransitionDurationMs,fullscreenDialog,opaque,barrierDismissible,barrierColor,restorationId. New on@AutoGoRouteShell:middleware,redirect,parentNavigatorKey,metadata,observers,restorationScopeId,notifyRootObserver,navigatorContainerBuilder. New on@AutoGoRouteBase:navigatorKey,initialExtra,errorPageBuilder,errorWidget,onException,onEnter,observers,refreshListenable,extraCodec,redirectLimit,routerNeglect,debugLogDiagnostics,overridePlatformDefaultLocation,requestFocus,restorationScopeId,caseSensitive,generateRouteEnum. @AutoGoRouteBranchforpreload,initialLocation,navigatorKey,observersandrestorationScopeIdon a stateful shell's branches — declared on the child, where branch identity actually lives.buildRouter({...})takes everyGoRouteroption, defaulting to the annotation, and the route tree is public asroutes. The package's own example no longer needs to hand-roll aGoRouter.AutoRouteTransitionwith ten presets and a publicbuildAutoRoutePage()so custom page builders can reuse them.- Generated conveniences:
locationOf…(build a URL without navigating),replaceInPlaceWith…(go_router'sreplace),fragment:on every helper,routeName/routeTemplateconstants per route, and anAppRouteenum of every route. state.metadataAs<T>(),getEnumParam,getParamList,extraAs<T>, andRouteParamFormatException, which names the parameter, the expected type and the raw value.- Dynamic routing: generated
buildRoutingConfig()andbuildDynamicRouter(routingConfig:)wrapGoRouter.routingConfig, so the route table can change at runtime while every other option keeps its annotation default. - Branch enums: every stateful shell gets a
<Shell>Branchenum in tab order, withgo,goFrom(context),ofandisActiveIn— no more baregoBranch(1)indices drifting whenorder:changes. - The barrel re-exports
go_routerand the handful of Flutter types generated code names (BuildContext,GlobalKey,ValueListenable, …), so a router library needs onlyimport 'package:auto_go_route/auto_go_route.dart'. - A
source_globsbuild option to narrow the annotation scan, and@AutoGoRouteBase(sourceGlobs:)to scope one router in a package with several. RouteCodeclist readers for every scalar type (boolList,numList,bigIntList,dateTimeList,uriList), andRouteRegistry.findClosestnow treats path parameters as wildcards and credits near-miss typos.- Every 1.x navigation helper removed from the API (
safePop,popOrHome,canPopSafely,goWithParams,goToNamed,popUntilRoute,GoRouter.location,safeLocation,safeCurrentRouteName) is back as a deprecated shim over its replacement. - 329 tests across the runtime (198), the generator (99) and the example
app (32), and a CI workflow covering the Flutter floor, both ends of the
generator's dependency range, four platform builds, codegen drift and
pub publish --dry-run. - AI assistant support: an
llms.txtbrief ships with the package, and the README has copy-paste prompts for setting the package up, converting a go_router configuration, upgrading from 1.x, adding screens, guards and bottom navigation, and fixing build errors. - Documentation: a restructured README with a table of contents, a screenshot gallery, collapsible reference sections and troubleshooting, plus MIGRATION.md and CONTRIBUTING.md. The example app was redesigned to show the live URL and decoded parameters on every screen, and its screenshots are the package's pub.dev gallery.
Changed #
- Requires
go_router >=17.5.0 <19.0.0, Flutter>=3.38.1, Dart>=3.10.0. (Flutter 3.38.0 itself bundles a pre-release Dart that>=3.10.0excludes.) The old floor (go_router: ^16.2.4withflutter: ">=3.0.0") was never satisfiable. - The annotation scan skips libraries whose source does not mention
AutoGoRoutebefore resolving them, which is most of the build cost on a large package;required_inputs: ['.dart']is gone, so this builder no longer runs behind every other Dart generator. NestedRoutePathsjoins paths with go_router's own algorithm, so the URL it builds is the URL go_router matches.RouteRegistry.scoped()creates an isolated registry;RouteRegistry()still returns the singleton.- Guard chains stay synchronous when their guards are, so a guarded route no longer defers navigation by a frame.
1.1.0 #
- Dependency updates.
1.0.9 #
- Add support for analyzer 7.0.0.
1.0.8 #
- Add support for pageBuilder.
- Enhance routing capabilities with new bottom sheet navigation features
1.0.7 #
- Add support for extra parameters.
- Fix nested routes.
1.0.6 #
- Enhance routing capabilities with new profile, settings, and notifications tabs; refactor ProfileRoute to use a tabbed interface.
1.0.5 #
- Fix pushRoute and pushToRoute methods to return Future<T?> instead of void.
1.0.4 #
- Fix redirect condition in AutoGoRouteGenerator to use fullPath instead of matchedLocation for accurate routing behavior.
1.0.3 #
- Queries are now optional.
1.0.2 #
- Added support for query parameters.
1.0.1 #
- Added support for middleware.
- Fixed some bugs.
1.0.0 #
- Initial release.
