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

flutter监听原生生命周期 #498

Closed
shownstrong opened this issue Nov 26, 2019 · 2 comments
Closed

flutter监听原生生命周期 #498

shownstrong opened this issue Nov 26, 2019 · 2 comments

Comments

@shownstrong
Copy link

flutter 页面 注册生命周期监听,当其他页面生命周期改变的时候, 注册过的页面都会收到消息。

这样有些在可见时的操作,会重复执行。现在想的是在页面增加一个字段,记录当前是否可见,但是这样每个Flutter页面都得这样搞一遍。

不确定框架是否能改成生命周期消息只通知生命周期有改变的Flutter页面,就像原生那样。

@xujim
Copy link
Collaborator

xujim commented Dec 17, 2019

@shownstrong, 有个api可以判断当前页面是否可见:

bool isTopContainer = FlutterBoost.BoostContainer.of(context).onstage

传入你widget的context,就能判断你的widget是否是可见的,如果不可见,则可以避免接收那些消息

@xujim
Copy link
Collaborator

xujim commented Dec 17, 2019

类似问题:#514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants