패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.0

hardware_buttons

iOS 및 Android용 플러터 플러그인으로 볼륨 버튼과 홈 버튼과 같은 다양한 하드웨어 버튼을 감지합니다.

30일 다운로드
50
좋아요
49
Pub 점수
40

패키지 설치

flutter pub add hardware_buttons

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

hardware_buttons 패키지는 iOS 및 Android 기기의 물리적 하드웨어 버튼(볼륨 업/다운 및 홈 버튼 포함)을 감지할 수 있는 Flutter 플러그인입니다. 이는 개발자가 앱 내 하드웨어 상호작용에 반응할 수 있도록 단순한 API를 제공하여 버튼 누름 이벤트를 듣도록 해줍니다. 이는 미디어 컨트롤, 탐색 단축키 또는 사용자 정의 장치별 동작에 특히 유용합니다. 이 플러그인은 두 플랫폼 모두를 지원하며 Flutter의 이벤트 시스템과 원활하게 통합됩니다. 저수준 하드웨어 입력 처리가 필요한 애플리케이션에 적합합니다.

사용 사례

  • 미디어 재생 제어
  • 사용자 정의 탐색 제스처
  • 기기별 앱 동작
  • 접근성 향상
  • 게임 컨트롤러 통합

주요 기능

  • 실시간 버튼 이벤트 감지
  • 크로스 플랫폼 지원 (iOS 및 안드로이드)
  • 간단한 이벤트 리스너 API
  • 경량이며 통합이 쉬움
  • 볼륨 및 홈 버튼 지원

적합한 대상

  • 하드웨어 상호작용이 필요한 모바일 앱
  • 미디어 플레이어 애플리케이션
  • 접근성 중심 앱
  • 물리적 조작을 사용하는 게임
  • 기기별 로직이 필요한 앱

고려 사항

  • 특정 하드웨어 버튼에 한정
  • 제3자 하드웨어 지원 없음
  • 플랫폼별 권한이 필요합니다
  • 모든 기기 모델에서 작동하지 않을 수 있습니다
  • 이벤트 처리는 OS 수준의 가용성에 따라 달라집니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

DEPRECATED

This plugin is deprecated :( We're no longer able to maintain it.

hardware_buttons

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

screenshots

Features

  • Detect volume buttons
  • Detect home button
  • Detect lock(power) button
  • To be added...

Android specification

  • If you subscribe to volume button events, this plugin will inevitably request for ACTION_MANAGER_OVERLAY_PERMISSION, since we found out this was the only way to do it well in Flutter Plugin environment. We do show permission request window for you, so there's nothing you should do other than subscribing to the event channel. However, since users may be surprised why your app needs this permission, we suggest notifying users beforehand why this permission will be requested.
  • Migrated to AndroidX as of version 1.0.0. To use with original support libraries, use version 0.2.4. Note, however, pre-AndroidX will no longer be supported.

iOS specification

  • No VOLUME_DOWN events are emitted when the volume is already at its minimum. VOLUME_UP events vice versa. On the other hand, events always occur whenever user presses the button on Android.

Usage

Import the package

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.

Use the plugin

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:

  1. Home button events, via homeButtonEvents.listen.
  2. Lock button events, via lockButtonEvents.listen.

Example

Find the example wiring in the example app.

API details

See the hardware_buttons.dart for more API details.

Issues and feedback

Please file issues to send feedback or report a bug. Thank you!

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.