搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.4

hardware_buttons_find_flutter

在具有不同按鈕的行動裝置上,監聽按鈕被按下的按鈕名稱。

Android
近 30 天下載
14
喜歡數
25
Pub 分數
135

安裝套件

flutter pub add hardware_buttons_find_flutter

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,讓開發者能夠偵測並回應 Android 設備上的硬體按鈕按下。它提供對特定按鈕事件(例如音量或電源按鈕)的即時監聽,讓應用程式能根據按下的按鈕名稱做出反應。非常適合根據實體輸入自訂裝置行為。此套件輕巧,可順暢整合至專注於 Android 的 Flutter 應用程式中。

適用情境

  • 自訂音量按鈕按壓處理
  • 檢測電源按鈕事件
  • 增強可存取性功能
  • 建構媒體控制應用
  • 建立基於手勢的互動
  • 開發特定於應用程式的硬體捷徑

主要特色

  • 即時按鈕事件偵測
  • 支援多個 Android 硬體按鈕
  • 用於按鈕名稱識別的簡單 API
  • 輕量且高效
  • 平台特定的 Android 實現
  • 輕鬆整合至Flutter應用

適合對象

  • 僅限 Android 的應用開發者
  • 需要硬體輸入自定義的應用程式
  • 面向可存取性的應用程式
  • 媒體播放器或控制應用
  • 開發互動式裝置體驗的開發者

使用建議

  • 僅限 Android 平台
  • 需要 Android 特定權限
  • 可能無法在所有裝置型號上運作
  • 無 iOS 支援
  • 行為可能因不同 Android 版本而異
  • 不適用於一般用途的按鈕處理

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Hardware Buttons Find Flutter

  • [x] Android

Overview

It is necessary to learn the feedback of buttons on different types of reading devices and take steps based on it. This plugin will help you. This code, written with Stream, always listens to the native code, returning the name of the button to you when the button is pressed. Based on the answer you get, write down the functions you envision.


logo

How to use it

class _MyAppState extends State<MyApp> {
  String? _latestHardwareButtonEvent;

  StreamSubscription<String>? _buttonSubscription;

  @override
  void initState() {
    super.initState();
    _buttonSubscription = HardwareButtons.buttonEvents?.listen((event) {
      setState(() {
        _latestHardwareButtonEvent = event.toString();
      });
    });
  }

  @override
  void dispose() {
    super.dispose();
    _buttonSubscription?.cancel();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Hardware buttons find'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text('Button name: $_latestHardwareButtonEvent\n'),
            ],
          ),
        ),
      ),
    );
  }
}

所屬分類

依賴

依賴清單 1 項

  • plugin_platform_interface^2.0.2

原始碼儲存庫

使用此套件的專案

暫無相關資料。