Skip to content
pubscout

flutter_android_volume_keydown

1.0.1, released 2 years ago by dart-tools.dev

Flutter plugin to listen for Android volume button presses and block default behavior.

WASM-ready
$ flutter pub add flutter_android_volume_keydown
Source repository

What it does

Provides a stream of hardware volume button events on Android. While listening, the buttons are prevented from changing the system volume. Stops listening restores normal button functionality.

AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to react to volume up/down presses in a Flutter app on Android
  • You want to intercept volume keys for custom shortcuts or UI controls

Skip it when

  • The app must run on iOS or other platforms
  • You need the volume buttons to keep controlling the system volume

Strengths

  • Simple API with a Dart stream
  • No extra permissions required
  • Compatible with Flutter 3.27

Weaknesses

  • Android‑only plugin
  • Requires MainActivity to extend a custom class
  • Blocks normal volume control while active

Setup

Kind
Plugin (native code)
Effort
Medium
Code generation
No
Direct dependencies
0

Change MainActivity.java or MainActivity.kt to extend FlutterAndroidVolumeKeydownActivity

var subscription = FlutterAndroidVolumeKeydown.stream.listen((event) {
  if (event == HardwareButton.volume_down) {
    print('Volume down received');
  } else if (event == HardwareButton.volume_up) {
    print('Volume up received');
  }
});
// later
subscription?.cancel();