flutter_android_volume_keydown 1.0.1 copy "flutter_android_volume_keydown: ^1.0.1" to clipboard
flutter_android_volume_keydown: ^1.0.1 copied to clipboard

PlatformAndroid

A simple plugin for listening to the Android volume keydown event

flutter_android_volume_keydown #

A simple flutter plugin for Android that listens to the volume up down button. It blocks the buttons from changing the volume while listening for events.

How to use #

Using the plugin is very simple:

  • Add flutter_android_volume_keydown to your pubspec.yaml
  • Change your MainActivity.java or MainActivity.kt to extend FlutterAndroidVolumeKeydownActivity
  • Implement a simple listener:
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");
      }
    });

To stop listening:

subscription?.cancel();

While listening the Volume button events are not handled by Android, when you stop listening the buttons resume their normal functionality again.

15
likes
150
points
867
downloads

Publisher

verified publisherdart-tools.dev

Weekly Downloads

A simple plugin for listening to the Android volume keydown event

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_android_volume_keydown