close method
void
close()
Close this Notify and fail all current and future waiters.
All currently waiting tasks will fail with StateError, and any future calls to notified will return a failed future.
Example:
// Force shutdown after grace period
Future<void> forceShutdown() async {
await Future.delayed(Duration(seconds: 30)); // Grace period
shutdownNotify.close(); // Force all remaining waiters to fail
}
Implementation
void close() {
if (_closed) return;
_closed = true;
while (_waiters.isNotEmpty) {
final c = _waiters.removeLast();
if (!c.isCompleted) {
c.completeError(StateError('Notify.disconnected'));
}
}
}