setSoundMode static method
Sets the device's sound mode.
Pass in either one of the following enum from RingerModeStatus to set the device's sound mode.
Throws PlatformException on Android API 24+ when Do Not Disturb access is not granted. Call PermissionHandler.openDoNotDisturbSetting first.
Implementation
static Future<RingerModeStatus> setSoundMode(RingerModeStatus profile) async {
final String enumStringValue;
switch (profile) {
case RingerModeStatus.normal:
enumStringValue =
await _channel.invokeMethod(_setNormalModeFunctionName);
case RingerModeStatus.silent:
enumStringValue =
await _channel.invokeMethod(_setSilentModeFunctionName);
case RingerModeStatus.vibrate:
enumStringValue =
await _channel.invokeMethod(_setVibrateModeFunctionName);
default:
enumStringValue = 'unknown';
}
_currentRingerStatus = _toEnum(enumStringValue);
return _currentRingerStatus;
}