diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 49764fbf95..bb8d8d7202 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -1,3 +1,8 @@ +## 8.0.4 + +- Updates documentations around `GoRouter.of`, `GoRouter.maybeOf`, and `BuildContext` extension. + + ## 8.0.3 - Makes namedLocation and route name related APIs case sensitive. diff --git a/packages/go_router/lib/src/misc/extensions.dart b/packages/go_router/lib/src/misc/extensions.dart index c4ff4ad6a9..58e3c3fea7 100644 --- a/packages/go_router/lib/src/misc/extensions.dart +++ b/packages/go_router/lib/src/misc/extensions.dart @@ -10,6 +10,8 @@ import '../router.dart'; /// context.go('/'); extension GoRouterHelper on BuildContext { /// Get a location from route name and parameters. + /// + /// This method can't be called during redirects. String namedLocation( String name, { Map pathParameters = const {}, diff --git a/packages/go_router/lib/src/router.dart b/packages/go_router/lib/src/router.dart index eac57c2255..15ceea6344 100644 --- a/packages/go_router/lib/src/router.dart +++ b/packages/go_router/lib/src/router.dart @@ -466,6 +466,8 @@ class GoRouter extends ChangeNotifier implements RouterConfig { } /// Find the current GoRouter in the widget tree. + /// + /// This method throws when it is called during redirects. static GoRouter of(BuildContext context) { final InheritedGoRouter? inherited = context.dependOnInheritedWidgetOfExactType(); @@ -474,6 +476,8 @@ class GoRouter extends ChangeNotifier implements RouterConfig { } /// The current GoRouter in the widget tree, if any. + /// + /// This method returns null when it is called during redirects. static GoRouter? maybeOf(BuildContext context) { final InheritedGoRouter? inherited = context.dependOnInheritedWidgetOfExactType(); diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml index a2f48a79a4..390811da2d 100644 --- a/packages/go_router/pubspec.yaml +++ b/packages/go_router/pubspec.yaml @@ -1,7 +1,7 @@ name: go_router description: A declarative router for Flutter based on Navigation 2 supporting deep linking, data-driven routes and more -version: 8.0.3 +version: 8.0.4 repository: https://github.com/flutter/packages/tree/main/packages/go_router issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22