时间计数继续更新时,当应用程序锁定在颤音中
我该如何计算应用程序锁定时的时间,因为我需要在第二次结束后导航到屏幕
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我该如何计算应用程序锁定时的时间,因为我需要在第二次结束后导航到屏幕
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
首先,您需要确定lifecylestate应用程序是否锁定。您可以查看
如何使用它是:将
与widgetsbindingobserver
添加到您的状态小部件,然后使用
didchangeapplifecyclestate
这样:到达计数时间时,查看
flutter_count_count_countdown_timer
软件包 https://pab.dev/packages/plutter_coutts_count_countdowndown_timer实现它,当应用程序暂停时,启动计时器。完成后,进行操作并在简历下,重置您的倒数计时器。请注意,您只需要在1个状态下的1个中写下它,它在全球范围内起作用。
First of all, you need to determine the lifecylestate if app is locked or not. You can have a look at https://api.flutter.dev/flutter/widgets/WidgetsBindingObserver/didChangeAppLifecycleState.html
How you use it is: Add
with WidgetsBindingObserver
to your Stateful Widget likethen use
didChangeAppLifecycleState
like this:When coming to counting time, look at
flutter_countdown_timer
package https://pub.dev/packages/flutter_countdown_timerImplement it and when app is paused, start your timer. When it finishes, do your operations and under resume, reset your countdown timer. Note that, you only need to write this in 1 of your StatefulWidgets, it works globally.