delete method
Future<bool>
delete({
- required HealthDataType type,
- required DateTime startTime,
- 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 thisvalue
is measured. Must be equal to or earlier thanendTime
.endTime
- the end time when thisvalue
is measured. Must be equal to or later thanstartTime
.
Implementation
Future<bool> delete({
required HealthDataType type,
required DateTime startTime,
DateTime? endTime,
}) async {
endTime ??= startTime;
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;
}