disconnect method

void disconnect()

Disconnects the audio nodes from the audio graph and resets them to null.

This should be called to clean up resources when the visualizer is no longer needed or if the audio source changes. Errors during disconnection are silently ignored.

Implementation

void disconnect() {
  try {
    _sourceNode?.disconnect();
    _analyserNode?.disconnect();
  } catch (e) {
    // Ignore
  }
  _sourceNode = null;
  _analyserNode = null;
}