[go_router]Updates documentations around GoRouter.of, GoRouter.maybeOf, and BuildContext extension. (#4176)

fixes https://github.com/flutter/flutter/issues/121506
This commit is contained in:
chunhtai
2023-06-15 09:10:17 -07:00
committed by GitHub
parent fa2e8a0528
commit f27d3c93f2
4 changed files with 12 additions and 1 deletions

View File

@ -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.

View File

@ -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<String, String> pathParameters = const <String, String>{},

View File

@ -466,6 +466,8 @@ class GoRouter extends ChangeNotifier implements RouterConfig<RouteMatchList> {
}
/// 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<InheritedGoRouter>();
@ -474,6 +476,8 @@ class GoRouter extends ChangeNotifier implements RouterConfig<RouteMatchList> {
}
/// 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<InheritedGoRouter>();

View File

@ -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