chenenyu / lifecycle

Lifecycle support for Flutter widgets.
https://pub.dev/packages/lifecycle
Apache License 2.0
48 stars 6 forks source link

App Lifecycle 和 页面 Lifecycle 冲突的问题 #24

Open imyyq-star opened 3 months ago

imyyq-star commented 3 months ago

Hi,请教个问题,我想要像类似 Android 那样,即可监听 App 去到后台的 Lifecycle 事件,又想要单个页面的 Lifecycle 事件,请问库支持吗? 我是用 SystemChannels.lifecycle.setMessageHandler 去监听 App 去到后台的事件的,但是发现如果我这么做了,再使用库,当我点击 Home 键使得 App 去到后台,App 当前页的 Lifecycle 事件没有被触发。似乎它们是二选一的。 请问该如何解决这种冲突呢?谢谢。

chenenyu commented 3 months ago

在flutter里监听前后台切换,使用WidgetsBinding.instance.addObserver(xxx)来实现