Skip to content

Upgrading go_router 2 to 3

Breaking2.5.7 → 3.1.1Breaking2New2Changed5Fixed1Other6

BreakingUpgrade verdict

2 breaking changes.

  • Calling pop() no longer needs a context, but it only pops pages managed by go_router instead of the underlying Navigator.
  • If you customize navigation with navigatorBuilder, your function now also receives the router state.
2 items need code or config changes

go_router publishes an official migration guide for version 3. It covers more than the release notes do.

Migrating to 3.0 section ↗

Flutter requirement changed in 3.0.2: >=1.17.0 → >=2.0.0.

Breaking2
Removes BuildContext from GoRouter.pop(), which now only pops the go_router page stack and no longer calls Navigator.pop().
GoRouter.pop()BuildContextNavigator.pop()
Adds GoRouterState to the navigatorBuilder function signature.
GoRouterStatenavigatorBuilder

Generated by DepDelta from published Dart source. Not mixed with prose notes.

  • changed: ctor GoRouter({ required List<GoRoute> routes, GoRouterPageBuilder? errorPageBuilder, GoRouterWidgetBuilder? errorBuilder, GoRouterRedirect? redirect, Listenable? refreshListenable, int redirectLimit = …, bool routerNeglect = …, String initialLocation = …, UrlPathStrategy? urlPathStrategy, List<NavigatorObserver>? observers, bool debugLogDiagnostics = …, TransitionBuilder? navigatorBuilder, Strin… → ctor GoRouter({ required List<GoRoute> routes, GoRouterPageBuilder? errorPageBuilder, GoRouterWidgetBuilder? errorBuilder, GoRouterRedirect? redirect, Listenable? refreshListenable, int redirectLimit = …, bool routerNeglect = …, String initialLocation = …, UrlPathStrategy? urlPathStrategy, List<NavigatorObserver>? observers, bool debugLogDiagnostics = …, GoRouterNavigatorBuilder? navigatorBuilder…
  • changed: ctor GoRouterRefreshStream(Stream stream) → ctor GoRouterRefreshStream(Stream<dynamic> stream)
  • changed: ctor GoRouterState( this._delegate, { required this.location, required this.subloc, required this.name, this.path, this.fullpath, this.params = …, this.queryParams = …, this.extra, this.error, ValueKey<String>? pageKey, }) → ctor GoRouterState( this._delegate, { required this.location, required this.subloc, required this.name, this.path, this.fullpath, this.params = …, String>{}, this.queryParams = …, String>{}, this.extra, this.error, ValueKey<String>? pageKey, })
  • changed: field GoRouter.routeInformationParser: final → field GoRouter.routeInformationParser: final GoRouteInformationParser
  • changed: method GoRoute.extractPathParams(Match match): Map<String, String> → method GoRoute.extractPathParams(RegExpMatch match): Map<String, String>
  • changed: method GoRoute.matchPatternAsPrefix(String loc): Match? → method GoRoute.matchPatternAsPrefix(String loc): RegExpMatch?
  • changed: method GoRouter.goNamed( String name, { Map<String, String> params = …, Map<String, String> queryParams = …, Object? extra, }): void → method GoRouter.goNamed( String name, { Map<String, String> params = …, String>{}, Map<String, String> queryParams = …, String>{}, Object? extra, }): void
  • changed: method GoRouter.namedLocation( String name, { Map<String, String> params = …, Map<String, String> queryParams = …, }): String → method GoRouter.namedLocation( String name, { Map<String, String> params = …, String>{}, Map<String, String> queryParams = …, String>{}, }): String
  • changed: method GoRouter.pop(BuildContext context): void → method GoRouter.pop(): void
  • changed: method GoRouter.pushNamed( String name, { Map<String, String> params = …, Map<String, String> queryParams = …, Object? extra, }): void → method GoRouter.pushNamed( String name, { Map<String, String> params = …, String>{}, Map<String, String> queryParams = …, String>{}, Object? extra, }): void
  • changed: method GoRouterHelper.goNamed( String name, { Map<String, String> params = …, Map<String, String> queryParams = …, Object? extra, }): void → method GoRouterHelper.goNamed( String name, { Map<String, String> params = …, String>{}, Map<String, String> queryParams = …, String>{}, Object? extra, }): void
  • changed: method GoRouterHelper.namedLocation( String name, { Map<String, String> params = …, Map<String, String> queryParams = …, }): String → method GoRouterHelper.namedLocation( String name, { Map<String, String> params = …, String>{}, Map<String, String> queryParams = …, String>{}, }): String
  • changed: method GoRouterHelper.pushNamed( String name, { Map<String, String> params = …, Map<String, String> queryParams = …, Object? extra, }): void → method GoRouterHelper.pushNamed( String name, { Map<String, String> params = …, String>{}, Map<String, String> queryParams = …, String>{}, Object? extra, }): void
  • changed: method GoRouterState.namedLocation( String name, { Map<String, String> params = …, Map<String, String> queryParams = …, }): String → method GoRouterState.namedLocation( String name, { Map<String, String> params = …, String>{}, Map<String, String> queryParams = …, String>{}, }): String
  • added: class GoRouteData: abstract
  • added: class InheritedGoRouter extends InheritedWidget
  • added: class TypedGoRoute<T extends GoRouteData>
  • added: ctor GoRouteData()
  • added: ctor InheritedGoRouter({ required Widget child, required this.goRouter, Key? key, })
  • added: ctor TypedGoRoute({ required this.path, this.routes = …, })
  • added: field InheritedGoRouter.goRouter: final GoRouter
  • added: field TypedGoRoute.path: final String
  • added: field TypedGoRoute.routes: final List<TypedGoRoute<GoRouteData>>
  • added: method GoRouteData.build(BuildContext context): Widget
  • added: method GoRouteData.buildPage(BuildContext context): Page<void>
  • added: method GoRouteData.redirect(): String?
  • added: method InheritedGoRouter.debugFillProperties(DiagnosticPropertiesBuilder properties): void
  • added: method InheritedGoRouter.updateShouldNotify(covariant InheritedGoRouter oldWidget): bool
  • added: static method GoRouteData.$location(String path, {Map<String, String>? queryParams}): String
  • added: static method GoRouteData.$route<T extends GoRouteData>({ required String path, required T Function(GoRouterState) factory, List<GoRoute> routes = …, }): GoRoute