setDefault method

Future<bool> setDefault(
  1. Device outputDevice, {
  2. DefaultType defaultType = DefaultType.all,
})

setDefault Output devices set all default types (Console, Multimedia, and Communications)

Implementation

Future<bool> setDefault(Device outputDevice, {DefaultType defaultType = DefaultType.all}) async {
  switch (defaultType) {
    case DefaultType.console:
      try {
        final command = 'SoundVolumeView /SetDefault "${outputDevice.itemID}" 0';
        await shell.run(command);
        return true;
      } catch (error) {
        return false;
      }
    case DefaultType.multimedia:
      try {
        final command = 'SoundVolumeView /SetDefault "${outputDevice.itemID}" 1';
        await shell.run(command);
        return true;
      } catch (error) {
        return false;
      }
    case DefaultType.communications:
        try {
        final command = 'SoundVolumeView /SetDefault "${outputDevice.itemID}" 2';
        await shell.run(command);
        return true;
      } catch (error) {
        return false;
      }
    case DefaultType.all:
      try {
        final command = 'SoundVolumeView /SetDefault "${outputDevice.itemID}" all';
        await shell.run(command);
        return true;
      } catch (error) {
        return false;
      }
  }
}