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

패키지 상세v1.2.0

holding_gesture

지정된 위젯을 길게 누르면 작동하는 사용자 지정 GestureDetector입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.8만
좋아요
49
Pub 점수
150

패키지 설치

flutter pub add holding_gesture

패키지 개요

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

holding_gesture 패키지는 사용자가 특정 위젯을 지정된 시간 동안 누르고 있을 때 작업을 트리거하는 사용자 정의 GestureDetector를 제공합니다. Flutter의 내장 GestureDetector를 확장하여 전용 힐드 감지 기능을 갖추고 있으며, 긴 누름 메뉴, 드래그 앤 드롭 시작, 컨텍스트에 민감한 제어와 같은 반응성 있고 직관적인 상호작용을 가능하게 합니다. 이 패키지는 가볍고 모바일, 웹, 데스크톱을 포함한 모든 주요 플랫폼과 호환됩니다. 뼈대 코드를 작성하지 않고도 힐드 기반 제스처를 구현하는 것을 간단하게 만듭니다.

사용 사례

  • 장시간 누르기 컨텍스트 메뉴
  • 손짓 기반의 탐색 트리거
  • 인터랙티브 위젯 활성화
  • 드래그 시작 감지
  • 사용자 정의 가능한 유지 기간
  • 접근성 향상된 컨트롤

주요 기능

  • 정확한 길게 누르기 지속 시간 제어
  • 크로스 플랫폼 호환성
  • 간단한 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.

카테고리

소스 저장소

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