delete method

Future<bool> delete(
  1. HealthDataType type,
  2. DateTime startTime,
  3. DateTime endTime
)

Deletes all records of the given type for a given period of time

Returns true if successful, false otherwise.

Parameters:

  • type - the value's HealthDataType
  • 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.

Implementation

Future<bool> delete(
    HealthDataType type, DateTime startTime, DateTime endTime) async {
  if (startTime.isAfter(endTime))
    throw ArgumentError("startTime must be equal or earlier than endTime");

  Map<String, dynamic> args = {
    'dataTypeKey': type.name,
    'startTime': startTime.millisecondsSinceEpoch,
    'endTime': endTime.millisecondsSinceEpoch
  };
  bool? success = await _channel.invokeMethod('delete', args);
  return success ?? false;
}