delete method
Deletes all records of the given type for a given period of time
Returns true if successful, false otherwise.
Parameters:
type
- the value's HealthDataTypestartTime
- 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
.
- It must be equal to or later than
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;
}