Upgrading go_router 8 to 9
Breaking8.2.0 → 9.1.1Breaking2New2Fixed2Other4
BreakingUpgrade verdict
2 breaking changes.
In plain terms
- Code that read the router's current location from the router object must now get it from the router state.
- The router object is no longer a ChangeNotifier, so code that listened to it as one must change.
Must act 2 items need code or config changes
go_router publishes an official migration guide for version 9. It covers more than the release notes do.
Migrating to go_router 9 ↗What you must change
Breaking2
Removes GoRouter.location; use GoRouterState.of().location instead.
GoRouter.locationGoRouterState.of()GoRouter no longer extends ChangeNotifier.
GoRouterChangeNotifierAPI changes
Generated by DepDelta from published Dart source. Not mixed with prose notes.
- removed:
get GoRouter.location: String - removed:
method GoRoute.toString(): String - changed:
class GoRouter extends ChangeNotifier implements RouterConfig<RouteMatchList> → class GoRouter implements RouterConfig<RouteMatchList> - changed:
class InheritedGoRouter extends InheritedNotifier<GoRouter> → class InheritedGoRouter extends InheritedWidget - changed:
class RouteBase: abstract → class RouteBase: abstract with Diagnosticable - changed:
static method ShellRouteData.$route<T extends ShellRouteData>({ required T Function(GoRouterState) factory, GlobalKey<NavigatorState>? navigatorKey, List<RouteBase> routes = …, }): ShellRoute → static method ShellRouteData.$route<T extends ShellRouteData>({ required T Function(GoRouterState) factory, GlobalKey<NavigatorState>? navigatorKey, GlobalKey<NavigatorState>? parentNavigatorKey, List<RouteBase> routes = …, List<NavigatorObserver>? observers, String? restorationScopeId, }): ShellRoute - added:
class GoError extends Error - added:
class GoException implements Exception - added:
class GoRouteInformationParser extends RouteInformationParser<RouteMatchList> - added:
class GoRouteInformationProvider extends RouteInformationProvider with WidgetsBindingObserver, ChangeNotifier - added:
class GoRouterDelegate extends RouterDelegate<RouteMatchList> with ChangeNotifier - added:
class ImperativeRouteMatch extends RouteMatch - added:
class RouteBuilder - added:
class RouteConfiguration - added:
class RouteInformationState<T> - added:
class RouteMatch - added:
class RouteMatchList - added:
class ShellRouteBase: abstract extends RouteBase - added:
class ShellRouteContext - added:
class StatefulShellBranchData: abstract - added:
class StatefulShellRouteData: abstract extends RouteData - added:
class TypedStatefulShellBranch<T extends StatefulShellBranchData> - added:
class TypedStatefulShellRoute<T extends StatefulShellRouteData> extends TypedRoute<T> - added:
ctor GoError(this.message) - added:
ctor GoException(this.message) - added:
ctor GoRouteInformationParser({ required this.configuration, required this.onParserException, }) - added:
ctor GoRouteInformationProvider({ required String initialLocation, required Object? initialExtra, Listenable? refreshListenable, }) - added:
ctor GoRouterDelegate({ required RouteConfiguration configuration, required GoRouterBuilderWithNav builderWithNav, required GoRouterPageBuilder? errorPageBuilder, required GoRouterWidgetBuilder? errorBuilder, required List<NavigatorObserver> observers, required this.routerNeglect, String? restorationScopeId, }) - added:
ctor ImperativeRouteMatch( {required super.pageKey, required this.matches, required this.completer}) - added:
ctor RouteBuilder({ required this.configuration, required this.builderWithNav, required this.errorPageBuilder, required this.errorBuilder, required this.restorationScopeId, required this.observers, required this.onPopPageWithRouteMatch, }) - added:
ctor RouteConfiguration({ required this.routes, required this.redirectLimit, required this.topRedirect, required this.navigatorKey, }) - added:
ctor RouteInformationState({ this.extra, this.completer, this.baseRouteMatchList, required this.type, }) - added:
ctor RouteMatch({ required this.route, required this.matchedLocation, required this.pageKey, }) - added:
ctor RouteMatchList({ required this.matches, required this.uri, this.extra, this.error, required this.pathParameters, }) - added:
ctor ShellRouteContext({ required this.route, required this.routerState, required this.navigatorKey, required this.routeMatchList, required this.navigatorBuilder, }) - added:
ctor StatefulShellBranchData() - added:
ctor StatefulShellRouteData() - added:
ctor TypedStatefulShellBranch({ this.routes = …, }) - added:
ctor TypedStatefulShellRoute({ this.branches = …, }) - added:
enum NavigatingType - added:
field GoError.message: final String - added:
field GoException.message: final String - added:
field GoRouteInformationParser.configuration: final RouteConfiguration - added:
field GoRouteInformationParser.debugParserFuture: Future<RouteMatchList>? - added:
field GoRouteInformationParser.onParserException: final ParserExceptionHandler? - added:
field GoRouterDelegate.builder: late final RouteBuilder - added:
field GoRouterDelegate.currentConfiguration: RouteMatchList - added:
field GoRouterDelegate.routerNeglect: final bool - added:
field ImperativeRouteMatch.completer: final Completer<Object?> - added:
field ImperativeRouteMatch.matches: final RouteMatchList - added:
field RouteBuilder.HeroController>: final Map<GlobalKey<NavigatorState>, HeroController> - added:
field RouteBuilder.builderWithNav: final GoRouterBuilderWithNav - added:
field RouteBuilder.configuration: final RouteConfiguration - added:
field RouteBuilder.errorBuilder: final GoRouterWidgetBuilder? - added:
field RouteBuilder.errorPageBuilder: final GoRouterPageBuilder? - added:
field RouteBuilder.observers: final List<NavigatorObserver> - added:
field RouteBuilder.onPopPageWithRouteMatch: final PopPageWithRouteMatchCallback - added:
field RouteBuilder.restorationScopeId: final String? - added:
field RouteConfiguration.String>: final Map<String, String> - added:
field RouteConfiguration.navigatorKey: final GlobalKey<NavigatorState> - added:
field RouteConfiguration.redirectLimit: final int - added:
field RouteConfiguration.routes: final List<RouteBase> - added:
field RouteConfiguration.topRedirect: final GoRouterRedirect - added:
field RouteInformationState.baseRouteMatchList: final RouteMatchList? - added:
field RouteInformationState.completer: final Completer<T?>? - added:
field RouteInformationState.extra: final Object? - added:
field RouteInformationState.type: final NavigatingType - added:
field RouteMatch.matchedLocation: final String - added:
field RouteMatch.pageKey: final ValueKey<String> - added:
field RouteMatch.route: final RouteBase - added:
field RouteMatchList.error: final GoException? - added:
field RouteMatchList.extra: final Object? - added:
field RouteMatchList.fullPath: final String - added:
field RouteMatchList.matches: final List<RouteMatch> - added:
field RouteMatchList.pathParameters: final Map<String, String> - added:
field RouteMatchList.uri: final Uri - added:
field ShellRouteContext.navigatorBuilder: final NavigatorBuilder - added:
field ShellRouteContext.navigatorKey: final GlobalKey<NavigatorState> - added:
field ShellRouteContext.route: final ShellRouteBase - added:
field ShellRouteContext.routeMatchList: final RouteMatchList - added:
field ShellRouteContext.routerState: final GoRouterState - added:
field TypedStatefulShellBranch.routes: final List<TypedRoute<RouteData>> - added:
field TypedStatefulShellRoute.branches: final List<TypedStatefulShellBranch<StatefulShellBranchData>> - added:
get GoRoute.redirectOnly: bool - added:
get GoRouteInformationProvider.value: RouteInformation - added:
get GoRouterDelegate.navigatorKey: GlobalKey<NavigatorState> - added:
get ImperativeRouteMatch.hashCode: int - added:
get RouteMatch.hashCode: int - added:
get RouteMatchList.hashCode: int - added:
get RouteMatchList.isEmpty: bool - added:
get RouteMatchList.isError: bool - added:
get RouteMatchList.isNotEmpty: bool - added:
get RouteMatchList.last: RouteMatch - added:
get RouteMatchList.routes: List<RouteBase> - added:
member NavigatingType.go - added:
member NavigatingType.push - added:
member NavigatingType.pushReplacement - added:
member NavigatingType.replace - added:
method GoError.toString(): String - added:
method GoException.toString(): String - added:
method GoRoute.debugFillProperties(DiagnosticPropertiesBuilder properties): void - added:
method GoRouteInformationParser.parseRouteInformation( RouteInformation routeInformation): Future<RouteMatchList> - added:
method GoRouteInformationParser.parseRouteInformationWithDependencies( RouteInformation routeInformation, BuildContext context, ): Future<RouteMatchList> - added:
method GoRouteInformationParser.restoreRouteInformation(RouteMatchList configuration): RouteInformation? - added:
method GoRouteInformationProvider.addListener(VoidCallback listener): void - added:
method GoRouteInformationProvider.didPushRoute(String route): Future<bool> - added:
method GoRouteInformationProvider.didPushRouteInformation(RouteInformation routeInformation): Future<bool> - added:
method GoRouteInformationProvider.dispose(): void - added:
method GoRouteInformationProvider.go(String location, {Object? extra}): void - added:
method GoRouteInformationProvider.notifyListeners(): void - added:
method GoRouteInformationProvider.push<T>(String location, {required RouteMatchList base, Object? extra}): Future<T?> - added:
method GoRouteInformationProvider.pushReplacement<T>(String location, {required RouteMatchList base, Object? extra}): Future<T?> - added:
method GoRouteInformationProvider.removeListener(VoidCallback listener): void - added:
method GoRouteInformationProvider.replace<T>(String location, {required RouteMatchList base, Object? extra}): Future<T?> - added:
method GoRouteInformationProvider.restore(String location, {required Object encodedMatchList}): void - added:
method GoRouteInformationProvider.routerReportsNewRouteInformation(RouteInformation routeInformation, {RouteInformationReportingType type = …}): void - added:
method GoRouterDelegate.build(BuildContext context): Widget - added:
method GoRouterDelegate.canPop(): bool - added:
method GoRouterDelegate.pop<T extends Object?>([T? result]): void - added:
method GoRouterDelegate.popRoute(): Future<bool> - added:
method GoRouterDelegate.setNewRoutePath(RouteMatchList configuration): Future<void> - added:
method ImperativeRouteMatch.complete([dynamic value]): void - added:
method ImperativeRouteMatch.operator ==(Object other): bool - added:
method InheritedGoRouter.updateShouldNotify(covariant InheritedWidget oldWidget): bool - added:
method RouteBase.debugFillProperties(DiagnosticPropertiesBuilder properties): void - added:
method RouteBuilder.Function( BuildContext context, GoRouterState state, ): Widget - added:
method RouteBuilder.build( BuildContext context, RouteMatchList matchList, bool routerNeglect, ): Widget - added:
method RouteBuilder.buildPage( BuildContext context, GoRouterState state, Widget child, ): Page<Object?> - added:
method RouteBuilder.buildState(RouteMatchList matchList, RouteMatch match): GoRouterState - added:
method RouteBuilder.pageBuilderForWidgetApp({ required LocalKey key, required String? name, required Object? arguments, required String restorationId, required Widget child, }): Page<void> - added:
method RouteBuilder.tryBuild( BuildContext context, RouteMatchList matchList, bool routerNeglect, GlobalKey<NavigatorState> navigatorKey, Map<Page<Object?>, GoRouterState> registry, ): Widget - added:
method RouteConfiguration.buildTopLevelGoRouterState(RouteMatchList matchList): GoRouterState - added:
method RouteConfiguration.debugKnownRoutes(): String - added:
method RouteConfiguration.findMatch(String location, {Object? extra}): RouteMatchList - added:
method RouteConfiguration.locationForRoute(RouteBase route): String? - added:
method RouteConfiguration.namedLocation( String name, { Map<String, String> pathParameters = …, String>{}, Map<String, dynamic> queryParameters = …, dynamic>{}, }): String - added:
method RouteConfiguration.redirect( BuildContext context, FutureOr<RouteMatchList> prevMatchListFuture, {required List<RouteMatchList> redirectHistory}): FutureOr<RouteMatchList> - added:
method RouteConfiguration.toString(): String - added:
method RouteMatch.operator ==(Object other): bool - added:
method RouteMatchList.operator ==(Object other): bool - added:
method RouteMatchList.push(ImperativeRouteMatch match): RouteMatchList - added:
method RouteMatchList.remove(RouteMatch match): RouteMatchList - added:
method RouteMatchList.toString(): String - added:
method ShellRoute.debugFillProperties(DiagnosticPropertiesBuilder properties): void - added:
method ShellRouteBase.buildPage(BuildContext context, GoRouterState state, ShellRouteContext shellRouteContext): Page<dynamic>? - added:
method ShellRouteBase.buildWidget(BuildContext context, GoRouterState state, ShellRouteContext shellRouteContext): Widget? - added:
method ShellRouteBase.navigatorKeyForSubRoute(RouteBase subRoute): GlobalKey<NavigatorState> - added:
method StatefulShellRoute.debugFillProperties(DiagnosticPropertiesBuilder properties): void - added:
method StatefulShellRouteData.builder( BuildContext context, GoRouterState state, StatefulNavigationShell navigationShell, ): Widget - added:
method StatefulShellRouteData.pageBuilder( BuildContext context, GoRouterState state, StatefulNavigationShell navigationShell, ): Page<void> - added:
static field RouteMatchList.empty: RouteMatchList - added:
static method RouteMatch.match({ required RouteBase route, required String remainingLocation, required String matchedLocation, required Map<String, String> pathParameters, }): RouteMatch? - added:
static method StatefulShellBranchData.$branch<T extends StatefulShellBranchData>({ GlobalKey<NavigatorState>? navigatorKey, List<RouteBase> routes = …, List<NavigatorObserver>? observers, String? initialLocation, String? restorationScopeId, }): StatefulShellBranch - added:
static method StatefulShellRouteData.$route<T extends StatefulShellRouteData>({ required T Function(GoRouterState) factory, required List<StatefulShellBranch> branches, GlobalKey<NavigatorState>? parentNavigatorKey, ShellNavigationContainerBuilder? navigatorContainerBuilder, String? restorationScopeId, }): StatefulShellRoute - added:
typedef GoRouterBuilderWithNav = Widget Function( BuildContext context, Widget child, ) - added:
typedef NavigatorBuilder = Widget Function( List<NavigatorObserver>? observers, String? restorationScopeId) - added:
typedef ParserExceptionHandler = RouteMatchList Function( BuildContext context, RouteMatchList routeMatchList, ) - added:
typedef PopPageWithRouteMatchCallback = bool Function( Route<dynamic> route, dynamic result, RouteMatch? match)