mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 23:51:55 +08:00
[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:
@ -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.
|
||||
|
@ -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>{},
|
||||
|
@ -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>();
|
||||
|
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user