setRingerMode static method

Future<void> setRingerMode(
  1. RingerMode mode
)

Sets the device sound mode. (Only for android)

Pass in either one of the following enum from RingerMode to set the device's sound mode.

Throws PlatformException if the current device's API version is 24 and above. Require user's grant for Do Not Disturb Access, call the function openNotificationPolicySettings before calling this function.

Implementation

static Future<void> setRingerMode(RingerMode mode) async {
  if(!Platform.isAndroid) {
    return;
  }

  final raw = RingerMode.values.indexOf(mode);
  if(raw != -1) {
    await _channel.invokeMethod("setRingerMode", {
      'mode': raw,
    });
  }
}