setVolume method Null safety

Future<bool?> setVolume(
  1. double volumeLevel,
  2. {StreamType streamType = StreamType.SYSTEM,
  3. bool showUI = false}
)

Changes the volumeLevel of the device for a specific streamType. You can also open the default device ui using showUI.

bool? volumeChanged = await RealVolume.setVolume(0.7, streamType: StreamType.MEDIA, showUI: true);

Implementation

static Future<bool?> setVolume(double volumeLevel,
    {StreamType streamType = StreamType.SYSTEM, bool showUI = false}) async {
  if (Platform.isIOS) return false;
  final bool? success = await _methodChannel.invokeMethod('setVolume', {
    'streamType': streamType.index,
    'volumeLevel': volumeLevel,
    'showUI': showUI ? 1 : 0
  });
  return success;
}