I've used health-3.0.3 in my flutter application to get the Google fit data. I'm able to get every data other than STEP-data which shows zero always.
You can refer to the health package here Health 3.0.3 Flutter
This is the code block to access the STEP datatype in my application
List<HealthDataType> types = [
HealthDataType.STEPS,
HealthDataType.WEIGHT,
//HealthDataType.HEIGHT,
];
setState(() => _state = AppState.FETCHING_DATA);
/// You MUST request access to the data types before reading them
bool accessWasGranted = await health.requestAuthorization(types);
double steps = 0;
if (accessWasGranted) {
try {
/// Fetch new data
List<HealthDataPoint> healthData =
await health.getHealthDataFromTypes(startDate, endDate, types);
/// Save all the new data points
_healthDataList.addAll(healthData);
} catch (e) {
print("Caught exception in getHealthDataFromTypes: $e");
}
/// Filter out duplicates
_healthDataList = HealthFactory.removeDuplicates(_healthDataList);
/// Print the results
_healthDataList.forEach((x) {
print("Data point: $x");
steps += (x.value as double);
});
print("Steps: $steps");
You can refer to the full code under the examples tab in the given link. Does anyone know what's wrong here?