tryDisconnect method

Future<void> tryDisconnect()

If the connection is not null, this method will close it.

If the connection is null, there is nothing that can be done anyway; so, do nothing here.

Implementation

Future<void> tryDisconnect() async {
  if (connection == null) return;

  await connection!.close();

  connection = null;
}