writeBloodPressure method
Saves blood pressure record into Apple Health or Google Fit.
Returns true if successful, false otherwise.
Parameters:
systolic
- the systolic part of the blood pressurediastolic
- the diastolic part of the blood pressurestartTime
- 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 pressure is measured only at a specific point in time.
- It must be equal to or later than
Implementation
Future<bool> writeBloodPressure(
int systolic, int diastolic, DateTime startTime, DateTime endTime) async {
if (startTime.isAfter(endTime))
throw ArgumentError("startTime must be equal or earlier than endTime");
Map<String, dynamic> args = {
'systolic': systolic,
'diastolic': diastolic,
'startTime': startTime.millisecondsSinceEpoch,
'endTime': endTime.millisecondsSinceEpoch
};
bool? success = await _channel.invokeMethod('writeBloodPressure', args);
return success ?? false;
}