Upgrading go_router 7 to 8
Breaking7.1.1 → 8.2.0Breaking3New2Fixed2Other3
BreakingUpgrade verdict
3 breaking changes.
In plain terms
- Routes pushed onto the navigation stack in code no longer update the browser address bar.
- Route names and named locations now treat uppercase and lowercase letters as different, so names that only differ in case no longer match.
- The browser back and forward buttons now account for routes pushed in code, not just URL navigation.
Must act 3 items need code or config changes
go_router publishes an official migration guide for version 8. It covers more than the release notes do.
Migrating to go_router 8 ↗What you must change
Breaking3
Imperatively pushed GoRoute no longer change URL.
GoRouteMakes namedLocation and route name related APIs case sensitive.
namedLocationBrowser backward and forward button respects imperative route operations.
API changes
Generated by DepDelta from published Dart source. Not mixed with prose notes.
- removed:
field GoRoute.parentNavigatorKey: final GlobalKey<NavigatorState>? - removed:
get GoRouter.routeInformationParser: GoRouteInformationParser - removed:
get GoRouter.routeInformationProvider: GoRouteInformationProvider - removed:
get GoRouter.routerDelegate: GoRouterDelegate - removed:
method GoRouter.locationForRoute(RouteBase route): String? - changed:
ctor GoRoute({ required this.path, this.name, this.builder, this.pageBuilder, this.parentNavigatorKey, this.redirect, super.routes = …, }) → ctor GoRoute({ required this.path, this.name, this.builder, this.pageBuilder, super.parentNavigatorKey, this.redirect, super.routes = …, }) - changed:
ctor GoRouter({ required List<RouteBase> routes, GoRouterPageBuilder? errorPageBuilder, GoRouterWidgetBuilder? errorBuilder, GoRouterRedirect? redirect, Listenable? refreshListenable, int redirectLimit = …, bool routerNeglect = …, String? initialLocation, Object? initialExtra, List<NavigatorObserver>? observers, bool debugLogDiagnostics = …, GlobalKey<NavigatorState>? navigatorKey, String? restor… → ctor GoRouter({ required List<RouteBase> routes, GoExceptionHandler? onException, GoRouterPageBuilder? errorPageBuilder, GoRouterWidgetBuilder? errorBuilder, GoRouterRedirect? redirect, Listenable? refreshListenable, int redirectLimit = …, bool routerNeglect = …, String? initialLocation, Object? initialExtra, List<NavigatorObserver>? observers, bool debugLogDiagnostics = …, GlobalKey<NavigatorSta… - changed:
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, }) → ctor GoRouterState( this._configuration, { required this.location, required this.matchedLocation, this.name, this.path, required this.fullPath, required this.pathParameters, required this.queryParameters, required this.queryParametersAll, this.extra, this.error, required this.pageKey, }) - changed:
ctor ShellRoute({ this.builder, this.pageBuilder, this.observers, super.routes, GlobalKey<NavigatorState>? navigatorKey, this.restorationScopeId, }) → ctor ShellRoute({ this.builder, this.pageBuilder, this.observers, required super.routes, super.parentNavigatorKey, GlobalKey<NavigatorState>? navigatorKey, this.restorationScopeId, }) - changed:
ctor StatefulShellRoute({ required this.branches, this.builder, this.pageBuilder, required this.navigatorContainerBuilder, this.restorationScopeId, }) → ctor StatefulShellRoute({ required this.branches, this.builder, this.pageBuilder, required this.navigatorContainerBuilder, super.parentNavigatorKey, this.restorationScopeId, }) - changed:
ctor StatefulShellRoute.indexedStack({ required List<StatefulShellBranch> branches, StatefulShellRouteBuilder? builder, StatefulShellRoutePageBuilder? pageBuilder, String? restorationScopeId, }) → ctor StatefulShellRoute.indexedStack({ required List<StatefulShellBranch> branches, StatefulShellRouteBuilder? builder, GlobalKey<NavigatorState>? parentNavigatorKey, StatefulShellRoutePageBuilder? pageBuilder, String? restorationScopeId, }) - changed:
field GoRouterState.error: final Exception? → field GoRouterState.error: final GoException? - changed:
method GoRouter.pushReplacement(String location, {Object? extra}): void → method GoRouter.pushReplacement<T extends Object?>(String location, {Object? extra}): Future<T?> - changed:
method GoRouter.pushReplacementNamed( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): void → method GoRouter.pushReplacementNamed<T extends Object?>( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): Future<T?> - changed:
method GoRouter.replace(String location, {Object? extra}): void → method GoRouter.replace<T>(String location, {Object? extra}): Future<T?> - changed:
method GoRouter.replaceNamed( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): void → method GoRouter.replaceNamed<T>( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, Object? extra, }): Future<T?> - added:
field GoRouter.configuration: late final RouteConfiguration - added:
field GoRouter.routeInformationParser: late final GoRouteInformationParser - added:
field GoRouter.routeInformationProvider: late final GoRouteInformationProvider - added:
field GoRouter.routerDelegate: late final GoRouterDelegate - added:
field RouteBase.parentNavigatorKey: final GlobalKey<NavigatorState>? - added:
method GoRouter.restore(RouteMatchList matchList): void - added:
static field GoRouter.optionURLReflectsImperativeAPIs: bool - added:
typedef GoExceptionHandler = void Function( BuildContext context, GoRouterState state, GoRouter router, )