Last updated:
0 purchases
flutter health
flutter_health #
This library combines both GoogleFit and AppleHealthKit. It support most of the values provided.
Works on from iOS 11.0. Some data types are supported from iOS 12.2.
Supports Android X
Dart package
Gitlab link
AppleHealthKit #
First Let's go through apple health kit:
Setup #
From Runner, select the Capabilities tab
Enable HealthKit
Check the Clinical Health Records box.
Then in the info.plist, Add string values for the following:
NSHealthUpdateUsageDescription
NSHealthShareUsageDescription
How to use #
Check if Apple Health is available on the device
await FlutterHealth.checkIfHealthDataAvailable()
copied to clipboard
Request authorization for the data types supported by the plugin
await FlutterHealth.requestAuthorization()
copied to clipboard
For now, you can request all of the options provided by the library
Get the samples of data types authorized by the user within the given time range
await FlutterHealth.getBodyFat(startDate, endDate)
copied to clipboard
await FlutterHealth.getHeartRate(startDate, endDate)
copied to clipboard
await FlutterHealth.getBloodPressureSys(startDate, endDate)
copied to clipboard
...
Data will be returning as a List of an object called HKHealthData. This object has the following attributes:
double value;
String unit;
int dateFrom;
int dateTo;
copied to clipboard
You can get those values with this library: #
Tested:
bodyFatPercentage
height
bodyMassIndex
waistCircumference
stepCount
basalEnergyBurned
activeEnergyBurned
heartRate
restingHeartRate
walkingHeartRateAverage
bodyTemperature
bloodPressureSystolic
bloodPressureDiastolic
oxygenSaturation
bloodGlucose
electrodermalActivity
Could not be tested without a watch:
highHeartRateEvent
lowHeartRateEvent
irregularHeartRhythmEvent
Full Example #
await FlutterHealth.checkIfHealthDataAvailable();
bool _isAuthorized = true;
DateTime startDate = DateTime.utc(2018);
DateTime endDate = DateTime.now();
var _dataList = List<HKHealthData>();
_isAuthorized = await FlutterHealth.requestAuthorization();
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getBodyFat(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getHeight(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getBodyMass(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getWaistCircumference(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getStepCount(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getBasalEnergyBurned(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getActiveEnergyBurned(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getHeartRate(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getRestingHeartRate(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getWalkingHeartRate(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getBodyTemperature(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getBloodPressureSys(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getBloodPressureDia(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getBloodOxygen(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getBloodGlucose(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getElectrodermalActivity(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getHKHighHeart(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getHKLowHeart(startDate, endDate));
if (_isAuthorized) _dataList.addAll(await FlutterHealth.getHKIrregular(startDate, endDate));
copied to clipboard
#GoogleFit
Setup #
For GoogleFit, the initial setup is a bit longer, and can get frustrating.
Just follow this setup.
How to use #
Request authorization for the data types supported by the plugin
await FlutterHealth.requestAuthorization()
copied to clipboard
For now, you can request all of the options provided by the library
Get the samples of data types authorized by the user within the given time range
For all data
await FlutterHealth.getGFAllData(startDate, endDate)
copied to clipboard
For specific type
await FlutterHealth.getGFBodyFat(startDate, endDate)
copied to clipboard
await FlutterHealth.getGFHeartRate(startDate, endDate)
copied to clipboard
await FlutterHealth.getGFBloodPressureSys(startDate, endDate)
copied to clipboard
...
Data will be returning as a List of an object called GFHealthData. This object has the following attributes:
String value;
String value2;
String unit;
int dateFrom;
int dateTo;
copied to clipboard
You can get those GoogleFit values with this library: #
bodyFatPercentage
height
stepCount
calories
heartRate
bodyTemperature
bloodPressure
oxygenSaturation
bloodGlucose
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.