release method

Future<void> release()

Releases the lock. Safe to call more than once. Only removes the file if it still holds our token, so a lock another acquirer has since reclaimed is never deleted out from under them.

Implementation

Future<void> release() async {
  _heartbeat?.cancel();
  _heartbeat = null;
  _tryDeleteIfMatches(_file, _token);
}