Skip to content

Commit 3b5cd81

Browse files
committed
release 0.6.0
1 parent f10a0b0 commit 3b5cd81

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.6.0] - 2022/07/01.
2+
3+
* Fix issue #23.
4+
15
## [0.5.0] - 2022/05/16.
26

37
* Flutter 3.

lib/src/lifecycle_observer.dart

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class LifecycleObserver extends NavigatorObserver with WidgetsBindingObserver {
1313
static final List<LifecycleObserver> _cache = [];
1414

1515
/// Avoid calling this constructor in [build] method.
16-
/// Call [dispose] when you will never use it.
16+
/// Call [dispose] when it will never be used, e.g. call it in State#dispose.
1717
LifecycleObserver() {
1818
_cache.add(this);
1919
WidgetsBinding.instance.addObserver(this);
@@ -23,16 +23,12 @@ class LifecycleObserver extends NavigatorObserver with WidgetsBindingObserver {
2323
@protected
2424
factory LifecycleObserver.internalGet(BuildContext context) {
2525
NavigatorState navigator = Navigator.of(context);
26-
LifecycleObserver? targetObserver;
2726
for (int i = _cache.length - 1; i >= 0; i--) {
2827
LifecycleObserver observer = _cache[i];
2928
if (observer.navigator == navigator) {
30-
targetObserver = observer;
29+
return observer;
3130
}
3231
}
33-
if (targetObserver != null) {
34-
return targetObserver;
35-
}
3632
throw Exception(
3733
'Can not get associated LifecycleObserver, did you forget to register it in MaterialApp or Navigator?');
3834
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: lifecycle
22
description: Lifecycle support for Flutter widgets.
3-
version: 0.5.0
3+
version: 0.6.0
44
homepage: https://github.com/chenenyu/lifecycle
55

66
environment:

0 commit comments

Comments
 (0)