FlutterVolumeController class
A Flutter plugin to control system volume and listen for volume changes on different platforms.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- showSystemUI ↔ bool
-
getter/setter pair
Static Methods
-
addListener(
ValueChanged< double> onChanged, {AudioStream stream = _defaultAudioStream, AudioSessionCategory category = _defaultAudioSessionCategory, bool emitOnStart = true}) → StreamSubscription<double> -
Listen for volume changes.
Use
emitOnStart
to control whether volume value should be emitted immediately right after the listener is attached. UseonChanged
to retrieve the updated volume level. Usestream
to set the audio stream type on Android. Usecategory
to set the audio session category type on iOS. -
getAndroidAudioStream(
) → Future< AudioStream?> - Get the current audio stream on Android.
-
getIOSAudioSessionCategory(
) → Future< AudioSessionCategory?> - Get the current audio session category on iOS.
-
getMute(
{AudioStream stream = _defaultAudioStream}) → Future< bool?> -
Check if the volume is muted.
On Android and iOS, we check if the current volume level is already
dropped to zero.
On macOS, Windows, Linux, we check if the mute switch is turned on.
Use
stream
to set the audio stream type on Android. -
getVolume(
{AudioStream stream = _defaultAudioStream}) → Future< double?> -
Get the current volume level. From 0.0 to 1.0.
Use
stream
to set the audio stream type on Android. -
lowerVolume(
double? step, {AudioStream stream = _defaultAudioStream}) → Future< void> -
Decrease the volume level by
step
. From 0.0 to 1.0. On Android and Windows, whenstep
is set to null, it will uses the default system stepping value. On iOS, macOS, Linux, ifstep
is not defined, the default stepping value is set to 0.15. Usestream
to set the audio stream type on Android. -
raiseVolume(
double? step, {AudioStream stream = _defaultAudioStream}) → Future< void> -
Increase the volume level by
step
. From 0.0 to 1.0. On Android and Windows, whenstep
is set to null, it will uses the default system stepping value. On iOS, macOS, Linux, ifstep
is not defined, the default stepping value is set to 0.15. Usestream
to set the audio stream type on Android. -
removeListener(
) → void - Remove the volume listener.
-
setAndroidAudioStream(
{AudioStream stream = _defaultAudioStream}) → Future< void> -
Set the default audio stream on Android.
Adjusts to the audio stream whose volume should be changed by the hardware volume controls.
Use
stream
to set the audio stream type on Android. Docs: https://developer.android.com/reference/android/media/AudioManager -
setIOSAudioSessionCategory(
{AudioSessionCategory category = _defaultAudioSessionCategory}) → Future< void> -
Set the default audio session category on iOS.
Adjusts to a different set of audio behaviors.
Use
category
to set the audio session category type on iOS. Docs: https://developer.apple.com/documentation/avfaudio/avaudiosession/category -
setMute(
bool isMuted, {AudioStream stream = _defaultAudioStream}) → Future< void> -
Mute or unmute the volume.
On Android and iOS, we either set the volume to zero or revert to the previous level.
On macOS, Windows, Linux, we control the mute switch. Volume will be restored
once it's unmuted.
Use
stream
to set the audio stream type on Android. -
setVolume(
double volume, {AudioStream stream = _defaultAudioStream}) → Future< void> -
Set the volume level. From 0.0 to 1.0.
Use
stream
to set the audio stream type on Android. -
toggleMute(
{AudioStream stream = _defaultAudioStream}) → Future< void> -
Toggle between the volume mute and unmute state.
Please refers to setMute for platform behaviors.
Use
stream
to set the audio stream type on Android. -
updateShowSystemUI(
bool isShown) → Future< void> -
Control system UI visibility.
Set
isShown
totrue
to display volume slider when changing volume. This setting only works on Android and iOS. Note: this setting doesn't control the volume slider invoked by physical buttons on Android.
Constants
- eventChannel → const EventChannel
- methodChannel → const MethodChannel