unlatch method
void
unlatch([
- T? partialResult
Opens the latch, notifying all listeners with the last cached value.
This method signals that the awaited task is complete. It will throw a StateError if called more than once before a reset.
partialResult: An optional result to provide at the moment of unlatching.
If provided, it is used. Otherwise, the last value from fire is used.
Implementation
void unlatch([T? partialResult]) {
if (_latchOpened) {
throw StateError('Cannot unlatch() after latch is already complete');
}
_latchOpened = true;
final result = partialResult ?? _cached;
if (result == null) {
throw StateError('Latch completed but no result was ever set!');
}
super.properties[this._property] = _cached;
}