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

パッケージ詳細v1.2.0

holding_gesture

特定のウィジェットを長押ししたときに反応するカスタマイズされたGestureDetector。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.8万
いいね数
49
Pub ポイント
150

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

flutter pub add holding_gesture

パッケージ概要

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

holding_gesture パッケージは、ユーザーが特定のウィジェットを定義された期間にわたり押しているときにアクションをトリガーするカスタマイズされた GestureDetector を提供します。Flutter の組み込み GestureDetector を拡張し、専用のホールド検出機能を備え、長押しメニュー、ドラッグアンドドロップの開始、コンテキストに応じたコントロールなどの反応性があり直感的なインタラクションを可能にします。このパッケージは軽量で、モバイル、Web、デスクトップを含むすべての主要プラットフォームと互換性があります。ボイラープレートコードを書かずにホールドベースのジェスチャーを実装することが簡単になります。

用途

  • 長押しコンテキストメニュー
  • ジェスチャーによるナビゲーションのトリガー
  • インタラクティブなウィジェットの有効化
  • ドラッグ開始の検出
  • カスタマイズ可能なホールド期間
  • アクセシビリティを強化したコントロール

主な機能

  • 正確な長押し持続時間の制御
  • クロスプラットフォーム互換性
  • シンプルな API インテグレーション
  • 設定可能なホールド遅延
  • 組み込みコールバック処理
  • 最小限のパフォーマンスオーバーヘッド

適している対象

  • インタラクティブなUIを構築する開発者
  • 長押し機能を必要とするアプリ
  • クロスプラットフォームのFlutterプロジェクト
  • アクセシビリティを重視したインターフェース
  • ジェスチャー中心のアプリケーション

注意事項

  • 正確なタイミングの設定が必要です
  • 他のジェスチャーディテクタと競合する可能性があります
  • 素早いタップのシーケンスには適していません
  • すべてのターゲットプラットフォームでテストが必要です
  • 単一ウィジェットのホールド検出に限定
  • Flutterのジェスチャー システムの安定性に依存しています

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

holding_gesture

A customized GestureDetector that acts on holding a determined Widget.

Getting Started

import 'package:holding_gesture/holding_gesture.dart';
HoldDetector

After importing, all you have to do is use HoldDetector the same way you already used GestureDetector! As it is on the documentation, its onTap override won't work when using a child that has onPressed or a similar callback, so you should pass the single tap behaviour to that.

HoldDetector(
  onHold: _incrementCounter,
  holdTimeout: Duration(milliseconds: 200),
  enableHapticFeedback: true,
  child: ElevatedButton(
    onPressed: _incrementCounter,
    child: Text("onHold"),
  ),
),
HoldTimeoutDetector

HoldTimeoutDetector works differently, you can use it to hold conditions or display something while the user is holding it for a predetermined time, and then execute an action after this duration passes, or canceling it if the hold action ceases. In the example, I'm using it to show a feedback on the button, and on the screen that something is loading, and then executing the increment once the timeout happens.

HoldTimeoutDetector(
  onTimeout: () {
    _incrementCounter();
    _updateLoading(false);
  },
  onTimerInitiated: () => _updateLoading(true),
  onCancel: () => _updateLoading(false),
  holdTimeout: Duration(milliseconds: 3000),
  enableHapticFeedback: true,
  child: ElevatedButton.icon(
    onPressed: () {},
    label: Text("onTimeout"),
    icon: _isLoading
        ? SizedBox(
            width: 16,
            height: 16,
            child: CircularProgressIndicator(
              strokeWidth: 2,
              valueColor: AlwaysStoppedAnimation(Colors.white),
            ),
          )
        : Icon(Icons.timer_3),
  ),
),

The main example, above and in example/, is the same as the default Flutter app, with the adition of a haptic feedback to each tick and the ability to hold the button to keep adding to the counter.

カテゴリー

ソースリポジトリ

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