writeNote method
Replaces the lock file's contents with text, such as the path the
lock protects, so a later cleanup can tell what it belonged to. Only
the holder writes. Read the note only once isHeld is false: on
Windows the lock is a mandatory byte-range lock, so no other handle
can read the file while it is held.
Implementation
Future<void> writeNote(String text) async {
final handle = _handle ?? (throw StateError('The lock was released.'));
await handle.write(text);
}