flutter_health 0.1.2 flutter_health: ^0.1.2 copied to clipboard
AppleHealthKit library that support most of the values provided.
flutter_health #
Apple Health Kit library for Flutter that support most of the values provided.
Works on from iOS 11.0. Some data types are supported from iOS 12.2.
How to use #
Check if Apple Health is available on the device
await await FlutterHealth.checkIfHealthDataAvailable()
Request authorization for the data types supported by the plugin
await FlutterHealth.requestAuthorization()
Get the samples of data types authorized by the user within the given time range
await FlutterHealth.getBodyFat(startDate, endDate)
await FlutterHealth.getHeartRate(startDate, endDate)
await FlutterHealth.getBloodPressureSys(startDate, endDate)
...
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;
Full Example #
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));
setState(() {});