Im writing a flutter program to receive the data from the google fit using the Health package,Im able to fetch weekly data as
weeklyStepData = await health.getTotalStepsInInterval(
now.subtract(const Duration(days: 7)), now);
But when i try to fetch the monthly data as
final yesterday = now.subtract(Duration(days: 30));
// var newDate = new DateTime(now.year, now.month, now.day - 29);
monthlyStepData =
await health.getTotalStepsInInterval(yesterday, now) ?? 0;
Its giving me exception "Caught exception in getTotalStepsInInterval: PlatformException(error, Must specify a valid minimum duration: -2134967296, null, java.lang.IllegalArgumentException: Must specify a valid minimum duration: -2134967296"
How to get the monthly steps data
To get the monthly step data,we need to use the function getHealthDataFromTypes of health package. From the result we can filter only the stepdata ,remove duplicates and add all the values