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

TimerUtil 倒计时进入后台后无法持续执行 #34

Open
xiejibiao opened this issue Mar 15, 2021 · 3 comments
Open

TimerUtil 倒计时进入后台后无法持续执行 #34

xiejibiao opened this issue Mar 15, 2021 · 3 comments

Comments

@xiejibiao
Copy link

TimerUtil 倒计时进入后台后无法持续执行,
操作步骤如下:
1)启动倒计时(60s)
2)最小化程序,进入后台,隔一小段时间后(两分钟),重新返回APP
3)发现倒计时依旧未执行完毕

@xiejibiao
Copy link
Author

若Debug无法复现,请打release 包测试,release 复现率更高,IOS设备全部有此问题,安卓华为亦有此问题

@xiejibiao
Copy link
Author

版本信息:
common_utils: ^1.2.4
`
run flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.7 19H2 darwin-x64, locale zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
[!] Android Studio (version 4.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Community Edition (version 2019.3.5)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.54.2)
[✓] Connected device (1 available)
! Error: test-07 is busy: Copying cache files from device. Xcode will continue when test-07 is finished. (code -10)

! Doctor found issues in 2 categories.
`

@chengmenghuiAndroid
Copy link

image
源码TimerUtil.startCountDown(),进入后台,callback 停止后,mTotalTime 的值也不变了。再次进入前台,callback 继续回调,mTotalTime 的值才改变,需要改成int time = mTotalTime - timer.tick;
Timer 有个属性: tick。即使 callback 停止回调了,tick 也是在一直在累加的
或者调用TimerUtil.startTimer(), tick是一直累加,外面回调逻辑需要改成int time = mTotalTime - timer.tick

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