パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.0.0

hardware_buttons

iOSおよびAndroid用のFlutterプラグインで、音量ボタンやホームボタンなどのさまざまなハードウェアボタンを検出します。

30日間ダウンロード
50
いいね数
49
Pub ポイント
40

パッケージをインストール

flutter pub add hardware_buttons

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

hardware_buttons パッケージは、iOS および Android デバイス上の物理的なハードウェアボタン(音量アップ/ダウンやホームボタンなど)の検出を可能にする Flutter プラグインです。このパッケージは、ボタンの押下イベントをリッスンするための簡単な API を提供し、開発者がアプリ内のハードウェア操作に応答できるようにします。これは、メディアコントロール、ナビゲーションショートカット、またはデバイス固有のカスタム動作に特に役立ちます。このプラグインは両方のプラットフォームをサポートしており、Flutter のイベントシステムとシームレスに統合されます。低レベルのハードウェア入力処理が必要なアプリケーションに最適です。

用途

  • メディア再生制御
  • カスタムナビゲーションジェスチャー
  • デバイス固有のアプリ動作
  • アクセシビリティの向上
  • ゲームコントローラーの統合

主な機能

  • リアルタイムボタンイベント検出
  • クロスプラットフォーム対応(iOS および Android)
  • シンプルなイベントリスナーAPI
  • 軽量で統合が簡単
  • ボリュームボタンとホームボタンをサポート

適している対象

  • ハードウェア操作が必要なモバイルアプリ
  • メディアプレイヤー アプリケーション
  • アクセシビリティを重視したアプリ
  • 物理コントロールを使用するゲーム
  • デバイス固有のロジックを必要とするアプリ

注意事項

  • 特定のハードウェアボタンに限定
  • サードパーティ製ハードウェアのサポートなし
  • プラットフォーム固有の権限が必要です
  • すべてのデバイスモデルで動作しない可能性があります
  • イベント処理は、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!

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。