dispose method

Future<void> dispose()

释放资源

Implementation

Future<void> dispose() async {
  try {
    // sound_stream 已移除
    await _amplitudeController?.close();

    // 释放对应平台的录音器
    if (!kIsWeb && Platform.isAndroid) {
      await _audioRecorder?.dispose();
      _audioRecorder = null;
    } else {
      _recorderController?.dispose();
      _recorderController = null;
    }

    _amplitudeController = null;
    _isRecorderInitialized = false;
  } catch (e) {
    print('❌ 释放录音器资源失败: $e');
  }
}