writeBloodOxygen method
Saves blood oxygen saturation record into Apple Health or Google Fit/Health Connect.
Returns true if successful, false otherwise.
Parameters:
saturation
- the saturation of the blood oxygen in percentageflowRate
- optional supplemental oxygen flow rate, only supported on Google Fit (default 0.0)startTime
- the start time when thisvalue
is measured.- It must be equal to or earlier than
endTime
.
- It must be equal to or earlier than
endTime
- the end time when thisvalue
is measured.- It must be equal to or later than
startTime
. - Simply set
endTime
equal tostartTime
if the blood oxygen saturation is measured only at a specific point in time.
- It must be equal to or later than
Implementation
Future<bool> writeBloodOxygen(
double saturation, DateTime startTime, DateTime endTime,
{double flowRate = 0.0}) async {
if (startTime.isAfter(endTime))
throw ArgumentError("startTime must be equal or earlier than endTime");
bool? success;
if (_platformType == PlatformType.IOS) {
success = await writeHealthData(
saturation, HealthDataType.BLOOD_OXYGEN, startTime, endTime);
} else if (_platformType == PlatformType.ANDROID) {
Map<String, dynamic> args = {
'value': saturation,
'flowRate': flowRate,
'startTime': startTime.millisecondsSinceEpoch,
'endTime': endTime.millisecondsSinceEpoch,
'dataTypeKey': HealthDataType.BLOOD_OXYGEN.name,
};
success = await _channel.invokeMethod('writeBloodOxygen', args);
}
return success ?? false;
}