close method

Future<void> close()

关闭流

Implementation

Future<void> close() async {
  if (_isClosed) return;
  _isClosed = true;
  await _subscription?.cancel();
  // 检查 controller 是否已关闭,防止重复关闭
  if (_controller != null && !_controller!.isClosed) {
    await _controller!.close();
  }
}