hardware_buttons
iOS 및 Android용 플러터 플러그인으로 볼륨 버튼과 홈 버튼과 같은 다양한 하드웨어 버튼을 감지합니다.
모든 하드웨어 버튼을 감지하는 Flutter 플러그인
{"sdk":"flutter"}{"sdk":"flutter"}아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
This plugin is deprecated :( We're no longer able to maintain it.
Version GitHub license
A Flutter plugin for iOS and Android for detecting various hardware buttons.
Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!
screenshots
1.0.0. To use with original support libraries, use version 0.2.4. Note, however, pre-AndroidX will no longer be supported.To use this plugin, follow the plugin installation instructions.
To use with AndroidX, install the latest version as above instructions. To use with original support libraries, install version 0.2.4 instead.
Add the following import to your Dart code:
import 'package:hardware_buttons/hardware_buttons.dart';
In order to listen to volume button events, use volumeButtonEvents.listen as below:
StreamSubscription _volumeButtonSubscription;
@override
void initState() {
super.initState();
_volumeButtonSubscription = volumeButtonEvents.listen((VolumeButtonEvent event) {
// do something
// event is either VolumeButtonEvent.VOLUME_UP or VolumeButtonEvent.VOLUME_DOWN
});
}
@override
void dispose() {
super.dispose();
// be sure to cancel on dispose
_volumeButtonSubscription?.cancel();
}
Besides volume button events, there are also:
homeButtonEvents.listen.lockButtonEvents.listen.Find the example wiring in the example app.
See the hardware_buttons.dart for more API details.
Please file issues to send feedback or report a bug. Thank you!