From fdddd88e50d4e0c98951eae0ae94a5dc01687766 Mon Sep 17 00:00:00 2001 From: Chun-Heng Tai Date: Fri, 9 Jun 2023 16:14:03 -0700 Subject: [PATCH] [go_router]Updates documentations around , , and extension. --- packages/go_router/CHANGELOG.md | 4 ++++ packages/go_router/lib/src/misc/extensions.dart | 2 ++ packages/go_router/lib/src/router.dart | 4 ++++ packages/go_router/pubspec.yaml | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/go_router/CHANGELOG.md b/packages/go_router/CHANGELOG.md index 173973a67e9..f24f5ab5a38 100644 --- a/packages/go_router/CHANGELOG.md +++ b/packages/go_router/CHANGELOG.md @@ -1,3 +1,7 @@ +## 8.0.2 + +- Updates documentations around `GoRouter.of`, `GoRouter.maybeOf`, and `BuildContext` extension. + ## 8.0.1 - Fixes a link for an example in `path` documentation. diff --git a/packages/go_router/lib/src/misc/extensions.dart b/packages/go_router/lib/src/misc/extensions.dart index c4ff4ad6a95..58e3c3fea7c 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 eac57c22558..15ceea63440 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 2d152daa8ae..f5cd92323bf 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.1 +version: 8.0.2 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