updateCurrentDevice method

  1. @override
Future<void> updateCurrentDevice(
  1. String device
)
override

Implementation

@override
Future<void> updateCurrentDevice(String device) async {
  if (device == '') {
    var res = await methodChannelProvider.callMethod(
        MethodCallOption.toggleSound, true);
    selectedAudioDevice = device;
    debugPrint('Turn off sound successfully with ${res?.result}');
    return;
  }
  MethodChannelResponse? updateDeviceResponse = await methodChannelProvider
      .callMethod(MethodCallOption.updateAudioDevice, device);
  if (updateDeviceResponse == null) {
    debugPrint(Response.null_audio_device_update);
    return;
  }

  if (updateDeviceResponse.result) {
    debugPrint("${updateDeviceResponse.arguments} to: $device");
    await methodChannelProvider.callMethod(
        MethodCallOption.toggleSound, false);
    selectedAudioDevice = device;
  } else {
    debugPrint("error: ${updateDeviceResponse.arguments}");
  }
}