writeBloodPressure method

Future<bool> writeBloodPressure(
  1. int systolic,
  2. int diastolic,
  3. DateTime startTime,
  4. DateTime endTime,
)

Saves blood pressure record into Apple Health or Google Fit.

Returns true if successful, false otherwise.

Parameters:

  • systolic - the systolic part of the blood pressure
  • diastolic - the diastolic part of the blood pressure
  • startTime - the start time when this value is measured.
    • It must be equal to or earlier than endTime.
  • endTime - the end time when this value is measured.
    • It must be equal to or later than startTime.
    • Simply set endTime equal to startTime if the blood pressure is measured only at a specific point in time.

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;
}