Health class

Main class for the Plugin. This class works as a singleton and should be accessed via Health() factory method. The plugin must be configured using the configure method before used.

Overall, the plugin supports:

In addition, the plugin has a set of specialized methods for reading and writing different types of health data:

Constructors

Health()
Get the singleton Health instance.
factory

Properties

deviceId String
The id of this device.
no setter
hashCode int
The hash code for this object.
no setterinherited
platformType HealthPlatformType
The type of platform of this device.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
useHealthConnectIfAvailable bool
Is this plugin using Health Connect (true) or Google Fit (false)?
no setter

Methods

configure({bool useHealthConnectIfAvailable = false}) Future<void>
Configure the health plugin. Must be called before using the plugin.
delete({required HealthDataType type, required DateTime startTime, DateTime? endTime}) Future<bool>
Deletes all records of the given type for a given period of time.
disconnect(List<HealthDataType> types, {List<HealthDataAccess>? permissions}) Future<bool?>
Disconnect from Google fit.
getHealthAggregateDataFromTypes({required List<HealthDataType> types, required DateTime startDate, required DateTime endDate, int activitySegmentDuration = 1, bool includeManualEntry = true}) Future<List<HealthDataPoint>>
Fetch a list of health data points based on types.
getHealthConnectSdkStatus() Future<HealthConnectSdkStatus?>
Returns the current status of Health Connect availability.
getHealthDataFromTypes({required List<HealthDataType> types, required DateTime startTime, required DateTime endTime, bool includeManualEntry = true}) Future<List<HealthDataPoint>>
Fetch a list of health data points based on types.
getHealthIntervalDataFromTypes({required DateTime startDate, required DateTime endDate, required List<HealthDataType> types, required int interval, bool includeManualEntry = true}) Future<List<HealthDataPoint>>
Fetch a list of health data points based on types.
getTotalStepsInInterval(DateTime startTime, DateTime endTime) Future<int?>
Get the total number of steps within a specific time period. Returns null if not successful.
hasPermissions(List<HealthDataType> types, {List<HealthDataAccess>? permissions}) Future<bool?>
Determines if the health data types have been granted with the specified access rights permissions.
installHealthConnect() Future<void>
Prompt the user to install the Health Connect app via the installed store (most likely Play Store).
isDataTypeAvailable(HealthDataType dataType) bool
Check if a given data type is available on the platform
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeDuplicates(List<HealthDataPoint> points) List<HealthDataPoint>
Return a list of HealthDataPoint based on points with no duplicates.
requestAuthorization(List<HealthDataType> types, {List<HealthDataAccess>? permissions}) Future<bool>
Requests permissions to access health data types.
revokePermissions() Future<void>
Revokes permissions of all types.
toString() String
A string representation of this object.
inherited
writeAudiogram({required List<double> frequencies, required List<double> leftEarSensitivities, required List<double> rightEarSensitivities, required DateTime startTime, DateTime? endTime, Map<String, dynamic>? metadata}) Future<bool>
Saves audiogram into Apple Health. Not supported on Android.
writeBloodOxygen({required double saturation, double flowRate = 0.0, required DateTime startTime, DateTime? endTime}) Future<bool>
Saves blood oxygen saturation record.
writeBloodPressure({required int systolic, required int diastolic, required DateTime startTime, DateTime? endTime}) Future<bool>
Saves a blood pressure record.
writeHealthData({required double value, HealthDataUnit? unit, required HealthDataType type, required DateTime startTime, DateTime? endTime}) Future<bool>
Write health data.
writeMeal({required MealType mealType, required DateTime startTime, required DateTime endTime, double? caloriesConsumed, double? carbohydrates, double? protein, double? fatTotal, String? name, double? caffeine}) Future<bool>
Saves meal record into Apple Health or Google Fit / Health Connect.
writeWorkoutData({required HealthWorkoutActivityType activityType, required DateTime start, required DateTime end, int? totalEnergyBurned, HealthDataUnit totalEnergyBurnedUnit = HealthDataUnit.KILOCALORIE, int? totalDistance, HealthDataUnit totalDistanceUnit = HealthDataUnit.METER, String? title}) Future<bool>
Write workout data to Apple Health or Google Fit or Google Health Connect.

Operators

operator ==(Object other) bool
The equality operator.
inherited