shutdown function

Future<void> shutdown(
  1. StreamChannel<Object?> channel,
  2. {bool serialize = true}

Sends a shutdown request over a channel.

On the remote side, the corresponding channel must have been passed to DriftServer.serve for this setup to work. Also, the DriftServer must have been configured to allow remote-shutdowns.


Future<void> shutdown(StreamChannel<Object?> channel, {bool serialize = true}) {
  final comm = DriftCommunication(channel, serialize: serialize);
  return comm
      // Sending a terminate request will stop the server, so we won't get a
      // response. This is expected and not an error we should throw.
      .onError<ConnectionClosedException>((error, stackTrace) => null)