setVolume method Null safety
- double volumeLevel,
- {StreamType streamType = StreamType.SYSTEM,
- 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;
}