Upgrading go_router 6 to 7
Breaking6.5.9 → 7.1.1Breaking8Fixed2Other1
BreakingUpgrade verdict
8 breaking changes.
In plain terms
- A property on the route state object got a clearer name. The automated fix command updates your code for you.
- The route state property holding path parameters is renamed. The automated fix command updates your code.
- The route state property for the full path is renamed to use consistent capitalization. The automated fix command updates your code.
- The route state property holding query parameters is renamed. The automated fix command updates your code.
Must act Top 3 of 8 that need code or config changes
go_router publishes an official migration guide for version 7. It covers more than the release notes do.
Migrating to go_router 7 ↗What you must change
Breaking8
Renames GoRouteState.subloc to GoRouteState.matchedLocation; run
dart fix --apply to migrate.GoRouteState.sublocGoRouteState.matchedLocationRenames GoRouteState.params to GoRouteState.pathParameters; run
dart fix --apply to migrate.GoRouteState.paramsGoRouteState.pathParametersRenames GoRouteState.fullpath to GoRouteState.fullPath; run
dart fix --apply to migrate.GoRouteState.fullpathGoRouteState.fullPathRenames GoRouteState.queryParams to GoRouteState.queryParameters; run
dart fix --apply to migrate.GoRouteState.queryParamsGoRouteState.queryParametersRenames params and queryParams in GoRouteState.namedLocation to pathParameters and queryParameters; run
dart fix --apply.GoRouteState.namedLocationparamsqueryParamspathParametersqueryParametersRenames params and queryParams in GoRouter's namedLocation, pushNamed, pushReplacementNamed and replaceNamed to pathParameters and queryParameters; run
dart fix --apply.GoRouter.namedLocationGoRouter.pushNamedGoRouter.pushReplacementNamedGoRouter.replaceNamedparamsqueryParamspathParametersqueryParametersRenames params and queryParams in BuildContext's namedLocation, pushNamed, pushReplacementNamed and replaceNamed to pathParameters and queryParameters; follow the migration guide.
BuildContext.namedLocationBuildContext.pushNamedBuildContext.pushReplacementNamedBuildContext.replaceNamedparamsqueryParamspathParametersqueryParametersCleans up the API and makes RouteMatchList immutable.
RouteMatchListAPI changes
Generated by DepDelta from published Dart source. Not mixed with prose notes.
- removed:
field GoRoute.pathParams: final List<String> - removed:
field GoRouterState.fullpath: final String? - removed:
field GoRouterState.params: final Map<String, String> - removed:
field GoRouterState.queryParams: final Map<String, String> - removed:
field GoRouterState.subloc: final String - removed:
get GoRouter.routeConfiguration: RouteConfiguration - changed:
class ShellRoute extends RouteBase → class ShellRoute extends ShellRouteBase - changed:
ctor GoRouterState( this._configuration, { required this.location, required this.subloc, required this.name, this.path, this.fullpath, this.params = …, String>{}, this.queryParams = …, String>{}, this.queryParametersAll = …, List<String>>{}, this.extra, this.error, required this.pageKey, }) → ctor GoRouterState( this._configuration, { required this.location, required this.matchedLocation, required this.name, this.path, this.fullPath, this.pathParameters = …, String>{}, this.queryParameters = …, String>{}, this.queryParametersAll = …, List<String>>{}, this.extra, this.error, required this.pageKey, }) - changed:
ctor ShellRoute({ this.builder, this.pageBuilder, this.observers, super.routes, GlobalKey<NavigatorState>? navigatorKey, }) → ctor ShellRoute({ this.builder, this.pageBuilder, this.observers, super.routes, GlobalKey<NavigatorState>? navigatorKey, this.restorationScopeId, }) - changed:
method GoRouter.goNamed( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, Object? extra, }): void → method GoRouter.goNamed( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): void - changed:
method GoRouter.namedLocation( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, }): String → method GoRouter.namedLocation( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, }): String - changed:
method GoRouter.pushNamed<T extends Object?>( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, Object? extra, }): Future<T?> → method GoRouter.pushNamed<T extends Object?>( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): Future<T?> - changed:
method GoRouter.pushReplacementNamed( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, Object? extra, }): void → method GoRouter.pushReplacementNamed( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): void - changed:
method GoRouter.replaceNamed( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, Object? extra, }): void → method GoRouter.replaceNamed( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): void - changed:
method GoRouterHelper.goNamed( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, Object? extra, }): void → method GoRouterHelper.goNamed( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): void - changed:
method GoRouterHelper.namedLocation( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, }): String → method GoRouterHelper.namedLocation( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, }): String - changed:
method GoRouterHelper.pushNamed<T extends Object?>( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, Object? extra, }): Future<T?> → method GoRouterHelper.pushNamed<T extends Object?>( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): Future<T?> - changed:
method GoRouterHelper.pushReplacementNamed( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, Object? extra, }): void → method GoRouterHelper.pushReplacementNamed( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): void - changed:
method GoRouterHelper.replaceNamed( String name, { Map<String, String> params = …, String>{}, Map<String, dynamic> queryParams = …, dynamic>{}, Object? extra, }): void → method GoRouterHelper.replaceNamed( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): void - changed:
method GoRouterState.namedLocation( String name, { Map<String, String> params = …, String>{}, Map<String, String> queryParams = …, String>{}, }): String → method GoRouterState.namedLocation( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, String> queryParameters = …, String>{}, }): String - added:
class StatefulNavigationShell extends StatefulWidget - added:
class StatefulNavigationShellState extends State<StatefulNavigationShell> with RestorationMixin - added:
class StatefulShellBranch - added:
class StatefulShellRoute extends ShellRouteBase - added:
ctor StatefulNavigationShell({ required this.shellRouteContext, required GoRouter router, required this.containerBuilder, }) - added:
ctor StatefulShellBranch({ required this.routes, GlobalKey<NavigatorState>? navigatorKey, this.initialLocation, this.restorationScopeId, this.observers, }) - added:
ctor StatefulShellRoute({ required this.branches, this.builder, this.pageBuilder, required this.navigatorContainerBuilder, this.restorationScopeId, }) - added:
ctor StatefulShellRoute.indexedStack({ required List<StatefulShellBranch> branches, StatefulShellRouteBuilder? builder, StatefulShellRoutePageBuilder? pageBuilder, String? restorationScopeId, }) - added:
field GoRoute.pathParameters: final List<String> - added:
field GoRouterState.fullPath: final String? - added:
field GoRouterState.matchedLocation: final String - added:
field GoRouterState.pathParameters: final Map<String, String> - added:
field GoRouterState.queryParameters: final Map<String, String> - added:
field ShellRoute.restorationScopeId: final String? - added:
field StatefulNavigationShell.containerBuilder: final ShellNavigationContainerBuilder - added:
field StatefulNavigationShell.currentIndex: final int - added:
field StatefulNavigationShell.shellRouteContext: final ShellRouteContext - added:
field StatefulNavigationShellState.Widget>: final Map<Key, Widget> - added:
field StatefulShellBranch.initialLocation: final String? - added:
field StatefulShellBranch.navigatorKey: final GlobalKey<NavigatorState> - added:
field StatefulShellBranch.observers: final List<NavigatorObserver>? - added:
field StatefulShellBranch.restorationScopeId: final String? - added:
field StatefulShellBranch.routes: final List<RouteBase> - added:
field StatefulShellRoute.branches: final List<StatefulShellBranch> - added:
field StatefulShellRoute.builder: final StatefulShellRouteBuilder? - added:
field StatefulShellRoute.navigatorContainerBuilder: final ShellNavigationContainerBuilder - added:
field StatefulShellRoute.pageBuilder: final StatefulShellRoutePageBuilder? - added:
field StatefulShellRoute.restorationScopeId: final String? - added:
get StatefulNavigationShell.route: StatefulShellRoute - added:
get StatefulNavigationShellState.currentIndex: int - added:
get StatefulNavigationShellState.restorationId: String? - added:
get StatefulNavigationShellState.route: StatefulShellRoute - added:
get StatefulShellBranch.defaultRoute: GoRoute? - added:
method GoRouter.locationForRoute(RouteBase route): String? - added:
method ShellRoute.buildPage(BuildContext context, GoRouterState state, ShellRouteContext shellRouteContext): Page<dynamic>? - added:
method ShellRoute.buildWidget(BuildContext context, GoRouterState state, ShellRouteContext shellRouteContext): Widget? - added:
method ShellRoute.navigatorKeyForSubRoute(RouteBase subRoute): GlobalKey<NavigatorState> - added:
method StatefulNavigationShell.createState(): State<StatefulWidget> - added:
method StatefulNavigationShell.goBranch(int index, {bool initialLocation = …}): void - added:
method StatefulNavigationShellState.build(BuildContext context): Widget - added:
method StatefulNavigationShellState.didUpdateWidget(covariant StatefulNavigationShell oldWidget): void - added:
method StatefulNavigationShellState.dispose(): void - added:
method StatefulNavigationShellState.goBranch(int index, {bool initialLocation = …}): void - added:
method StatefulNavigationShellState.initState(): void - added:
method StatefulNavigationShellState.restoreState(RestorationBucket? oldBucket, bool initialRestore): void - added:
method StatefulShellRoute.buildPage(BuildContext context, GoRouterState state, ShellRouteContext shellRouteContext): Page<dynamic>? - added:
method StatefulShellRoute.buildWidget(BuildContext context, GoRouterState state, ShellRouteContext shellRouteContext): Widget? - added:
method StatefulShellRoute.navigatorKeyForSubRoute(RouteBase subRoute): GlobalKey<NavigatorState> - added:
static method RouteBase.routesRecursively(Iterable<RouteBase> routes): Iterable<RouteBase> - added:
static method StatefulNavigationShell.maybeOf(BuildContext context): StatefulNavigationShellState? - added:
static method StatefulNavigationShell.of(BuildContext context): StatefulNavigationShellState - added:
typedef ShellNavigationContainerBuilder = Widget Function(BuildContext context, StatefulNavigationShell navigationShell, List<Widget> children) - added:
typedef ShellRouteBuilder = Widget Function( BuildContext context, GoRouterState state, Widget child, ) - added:
typedef ShellRoutePageBuilder = Page<dynamic> Function( BuildContext context, GoRouterState state, Widget child, ) - added:
typedef StatefulShellRouteBuilder = Widget Function( BuildContext context, GoRouterState state, StatefulNavigationShell navigationShell, ) - added:
typedef StatefulShellRoutePageBuilder = Page<dynamic> Function( BuildContext context, GoRouterState state, StatefulNavigationShell navigationShell, )