volume_listener
0.1.0, released 2 years ago by folksable.com
A Flutter plugin to listen to volume button press events on Android and iOS.
What it does
It allows Flutter apps to listen for volume button press events (up, down, and capture) on both Android and iOS platforms. Developers can register a listener callback to handle these hardware button events and remove it when no longer needed.
AI-written summary of version 0.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to detect physical volume button presses in your app
- You want to handle hardware camera capture button events on iOS 17.2+
Skip it when
- You only need to play or record audio
- You need complex media session management
Strengths
- Cross-platform support for Android and iOS
- Simple API with straightforward add and remove listener methods
Weaknesses
- Requires manual modification of the Android MainActivity class
- Limited to volume and capture button events
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 1
On Android, you must extend your MainActivity with VolumeListenerActivity and remove FlutterActivity.
VolumeListener.addListener((VolumeKey event) {
switch (event) {
case VolumeKey.up:
print('Volume Up'); break;
case VolumeKey.down:
print('Volume Down'); break;
case VolumeKey.capture:
print('iOS Hardware Camera Capture');
break;
}
});
VolumeListener.removeListener();Alternatives
Packages that do the same job and could replace volume_listener.
- flutter_recorder
Low-level cross-platform audio recorder plugin using miniaudio with real-time waveform, FFT and volume.
87Compare - ffmpeg_kit_flutter_new_audio
Run FFmpeg and FFprobe commands from Dart with prebuilt audio codecs for multiple platforms.
79Compare - flutter_media_session
Flutter plugin for OS media integration across Android, iOS, macOS, Windows, Linux, and Web
78Compare - flutter_volume_controller
Control system volume and listen for volume changes across multiple platforms.
71Compare
Works with
Packages commonly used together with volume_listener: ones it builds on, ones built on it, and its own family.