delete method

Future<K> delete(
  1. K id
)

Deletes the data with the specified ID.

Throws an exception if the data with the given ID does not exist.

Returns the ID of the deleted data.

Implementation

Future<K> delete(K id) async {
  final file = File('${directory.path}/$id.json');
  if (!await file.exists()) {
    throw Exception('Data with ID $id does not exist.');
  }
  await file.delete();
  return id;
}