Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[go_router] Don't log if hierarchicalLoggingEnabled is true #6019

Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fc3709d
bug: Don't log if hierarchicalLoggingEnabled is true
ValentinVignal Jan 31, 2024
c3a0794
chore: Update the version
ValentinVignal Jan 31, 2024
69e2dfc
Merge remote-tracking branch 'upstream/main' into go-router/don-t-log…
ValentinVignal Feb 14, 2024
bd14b32
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Feb 26, 2024
16cad7a
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Feb 28, 2024
6031c24
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Mar 4, 2024
64edef1
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Mar 12, 2024
3f319d1
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Mar 14, 2024
e513c22
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Mar 15, 2024
998a25e
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Mar 16, 2024
a824c90
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Mar 18, 2024
df0ea66
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Mar 21, 2024
b2cac28
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Mar 24, 2024
1f06814
Merge remote-tracking branch 'upstream/main' into go-router/don-t-log…
ValentinVignal Apr 1, 2024
8401b64
Merge remote-tracking branch 'upstream/main' into go-router/don-t-log…
ValentinVignal Apr 9, 2024
5e65ecb
fix: Remove bad batch
ValentinVignal Apr 9, 2024
19452e7
Merge remote-tracking branch 'upstream/main' into go-router/don-t-log…
ValentinVignal Apr 12, 2024
82ee0bc
Merge remote-tracking branch 'upstream/main' into go-router/don-t-log…
ValentinVignal Apr 13, 2024
55e6730
refactor: Add mockable developerLog method
ValentinVignal Apr 13, 2024
213841f
test: Update the tests
ValentinVignal Apr 13, 2024
9b24e7a
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Apr 16, 2024
9f9ef3c
Merge branch 'main' into go-router/don-t-log-if-hierarchical-logging-…
ValentinVignal Apr 18, 2024
bb86864
Merge remote-tracking branch 'upstream/main' into go-router/don-t-log…
ValentinVignal Apr 25, 2024
b86d0cb
Merge branch 'go-router-builder/add-on-exit' into go-router/don-t-log…
ValentinVignal Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions packages/go_router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 13.2.3

- Fixes unwanted logs when `hierarchicalLoggingEnabled` was set to `true`.

## 13.2.2

- Fixes restoreRouteInformation issue when GoRouter.optionURLReflectsImperativeAPIs is true and the last match is ShellRouteMatch
Expand All @@ -18,7 +22,7 @@

## 13.0.1

* Fixes new lint warnings.
- Fixes new lint warnings.

## 13.0.0

Expand All @@ -29,12 +33,12 @@

## 12.1.3

* Fixes a typo in `navigation.md`.
- Fixes a typo in `navigation.md`.

## 12.1.2

* Fixes an incorrect use of `extends` for Dart 3 compatibility.
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
- Fixes an incorrect use of `extends` for Dart 3 compatibility.
- Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.

## 12.1.1

Expand Down Expand Up @@ -109,7 +113,7 @@

## 10.1.2

* Adds pub topics to package metadata.
- Adds pub topics to package metadata.

## 10.1.1

Expand Down Expand Up @@ -440,7 +444,7 @@

- Fixes a bug where intermediate route redirect methods are not called.
- GoRouter implements the RouterConfig interface, allowing you to call
MaterialApp.router(routerConfig: _myGoRouter) instead of passing
MaterialApp.router(routerConfig: \_myGoRouter) instead of passing
the RouterDelegate, RouteInformationParser, and RouteInformationProvider
fields.
- **BREAKING CHANGE**
Expand Down
2 changes: 2 additions & 0 deletions packages/go_router/lib/src/delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
// This should be the only place where the last GoRoute exit the screen.
final GoRoute lastRoute = currentConfiguration.last.route;
if (lastRoute.onExit != null && navigatorKey.currentContext != null) {
walker.buildState(_configuration, _configuration.);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unrelated?


return !(await lastRoute.onExit!(navigatorKey.currentContext!));
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/lib/src/logging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ StreamSubscription<LogRecord>? _subscription;
void setLogging({bool enabled = false}) {
_subscription?.cancel();
_enabled = enabled;
if (!enabled) {
if (!enabled || hierarchicalLoggingEnabled) {
return;
}

Expand Down
9 changes: 9 additions & 0 deletions packages/go_router/lib/src/route_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ abstract class GoRouteData extends RouteData {
/// Corresponds to [GoRoute.redirect].
FutureOr<String?> redirect(BuildContext context, GoRouterState state) => null;

/// Called when this route is removed from GoRouter's route history.
///
/// Corresponds to [GoRoute.onExit].
FutureOr<bool> onExit(BuildContext context) => true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this from other patch? we should probably separate this out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops yeah, that's a mistake. I reverted it


/// A helper function used by generated code.
///
/// Should not be used directly.
Expand Down Expand Up @@ -106,12 +111,16 @@ abstract class GoRouteData extends RouteData {
FutureOr<String?> redirect(BuildContext context, GoRouterState state) =>
factoryImpl(state).redirect(context, state);

FutureOr<bool> onExit(BuildContext context) =>
factoryImpl(state).onExit(context);

return GoRoute(
path: path,
name: name,
builder: builder,
pageBuilder: pageBuilder,
redirect: redirect,
onExit: onExit,
routes: routes,
parentNavigatorKey: parentNavigatorKey,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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: 13.2.2
version: 13.2.3
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

Expand Down