简体   繁体   English

即使应用程序在 flutter 中被杀死,如何在后台运行倒数计时器功能?

[英]How to run countdown timer functionality in the background even the app is killed in flutter?

I am new in flutter. I am making a countdown timer app in flutter. The next thing I need to know that "How I can run my selected Countdown time in the background?"我是 flutter 的新手。我正在 flutter 制作一个倒计时应用程序。接下来我需要知道“如何在后台运行我选择的倒计时时间?” I had done this functionality in native android Kotlin, but I need to get this task done in flutter.我已经在本机 android Kotlin 中完成了此功能,但我需要在 flutter 中完成此任务。

Any suggestion for this functionality in flutter?在 flutter 中对这个功能有什么建议吗?

I had used timer.periodic but when I close my app the time starts from the given time.我曾经使用过 timer.periodic 但是当我关闭我的应用程序时,时间从给定时间开始。 It should be to run in the background.应该是在后台运行。

As you said that you implement it in native android, you can not run Dart code to run in the background until you contact the native features, you need a work manager package for this, like:正如你所说,你在本机 android 中实现它,你不能运行Dart代码在后台运行,直到你接触本机功能,你需要一个工作经理 package 为此,例如:

https://pub.dev/packages/workmanager https://pub.dev/packages/workmanager

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM