write method

Future<void> write(
  1. FutureOr<T> callback(
    1. T value
    )
)

Writes the value of the object.

Parameters:

  • callback: The callback function that performs the writing.

Implementation

Future<void> write(FutureOr<T> Function(T value) callback) async {
  await _lock.acquire();
  try {
    _writeCount++;
    _value = await callback(_value);
  } finally {
    _writeCount--;
    await _lock.release();
  }
}