mirror of
https://github.com/flutter/packages.git
synced 2025-06-20 22:52:50 +08:00
[go_router] Don't clear listeners when logging is disabled (#2533)
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
## 4.4.1
|
||||||
|
|
||||||
|
- Fix an issue where disabling logging clears the root logger's listeners
|
||||||
|
|
||||||
## 4.4.0
|
## 4.4.0
|
||||||
|
|
||||||
- Adds `buildPageWithState` to `GoRouteData`.
|
- Adds `buildPageWithState` to `GoRouteData`.
|
||||||
|
@ -16,7 +16,6 @@ StreamSubscription<LogRecord>? _subscription;
|
|||||||
void setLogging({bool enabled = false}) {
|
void setLogging({bool enabled = false}) {
|
||||||
_subscription?.cancel();
|
_subscription?.cancel();
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
log.clearListeners();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: go_router
|
name: go_router
|
||||||
description: A declarative router for Flutter based on Navigation 2 supporting
|
description: A declarative router for Flutter based on Navigation 2 supporting
|
||||||
deep linking, data-driven routes and more
|
deep linking, data-driven routes and more
|
||||||
version: 4.4.0
|
version: 4.4.1
|
||||||
repository: https://github.com/flutter/packages/tree/main/packages/go_router
|
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
|
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22
|
||||||
|
|
||||||
|
@ -7,21 +7,11 @@ import 'package:go_router/src/logging.dart';
|
|||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// Reset the logger before each test.
|
test('setLogging does not clear listeners', () {
|
||||||
setUp(() {
|
log.onRecord
|
||||||
setLogging();
|
.listen(expectAsync1<void, LogRecord>((LogRecord r) {}, count: 2));
|
||||||
});
|
|
||||||
test('setLogging enables log messages on the logger', () {
|
|
||||||
log.onRecord.listen(expectAsync1<void, LogRecord>((LogRecord r) {}));
|
|
||||||
|
|
||||||
setLogging(enabled: true);
|
setLogging(enabled: true);
|
||||||
log.info('message');
|
log.info('message');
|
||||||
});
|
|
||||||
|
|
||||||
test('setLogging disables log messages on the logger', () {
|
|
||||||
log.onRecord
|
|
||||||
.listen(expectAsync1<void, LogRecord>((LogRecord r) {}, count: 0));
|
|
||||||
|
|
||||||
setLogging();
|
setLogging();
|
||||||
log.info('message');
|
log.info('message');
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user