I am trying to build a basic fitness app using flutter. The app has two main features:
- Daily steps counter
- graph of historical data (number of steps each day)
I use the pedometer plugin to retrieve data from the sensors of the phone. My problem is that the plugin can only send the continuous step counting since the last reboot that means if the user does not open my app for serval days, I don't know how many steps he walked each day only the total number of steps he did. I thought about letting my app run in the background but it will be a waste of battery
P.s I read Implementing pedometer in flutter article by Masky, but it is not solving my problem.
Thanks for any kind of help :)
Excerpt from: https://hub.packtpub.com/step-detector-and-step-counters-sensors/
Of the returned
SensorEvent
, the 1st value represents the number of steps since the last boot and it also contains atimestamp
which is the amount of nanoseconds elapsed from the time of last device boot.This site advises to use JobScheduler to "schedule periodic job to retrieve the total step count under suitable interval."
On the first site it explains how to maintain step history in case that's what you want, there's also sample code there.