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

패키지 상세v1.1.1

gesture_x_detector

여러 유형(Tap, DoubleTap, Scale, Long-Press, Move)을 지원하는 가벼운 제스처 감지기이며, 모든 콜백을 동시에 사용할 수 있습니다

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.7만
좋아요
63
Pub 점수
150

패키지 설치

flutter pub add gesture_x_detector

패키지 개요

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

GestureXDetector는 탭, 더블탭, 스케일, 긴 누름, 이동 등 여러 제스처를 동시에 감지할 수 있는 가벼운 Flutter 패키지입니다. 각 제스처 유형에 대해 유연한 콜백 지원을 제공하여 개발자가 복잡한 사용자 상호작용을 통합된 방식으로 처리할 수 있도록 합니다. 크로스플랫폼 사용을 위해 설계되어 Android, iOS, 웹, macOS, Windows, Linux에서 원활하게 작동합니다. 추가적인 복잡성을 증가시키지 않고 반응성 있는 터치 피드백이 필요한 인터랙티브 UI에 이상적입니다.

사용 사례

  • 인터랙티브 그림 앱
  • 확대 가능한 이미지 뷰어
  • 드래그 앤 드롭 인터페이스
  • 멀티터치 제스처 인식
  • 손짓 기반의 사용자 정의 컨트롤

주요 기능

  • 동시에 여러 제스처를 지원합니다
  • 모든 콜백을 동시에 사용할 수 있습니다
  • 경량이고 효율적
  • 크로스 플랫폼 호환성
  • 간단한 API 통합
  • 실시간 제스처 감지

적합한 대상

  • 인터랙티브 UI를 구축하는 개발자
  • 다중 터치 입력이 필요한 앱
  • 반응형 제스처 처리가 필요한 프로젝트
  • 크로스 플랫폼 터치 애플리케이션
  • 손짓 중심 기능의 프로토타이핑

고려 사항

  • 겹치는 제스처와 함께 주의 깊은 상태 관리가 필요할 수 있습니다
  • 매우 높은 주파수의 제스처 이벤트에 대한 성능 영향
  • 매우 복잡한 제스처 체인에 최적화되지 않음
  • 제한된 내장 제스처 조합
  • 중간에서 고급 수준의 제스처 논리에 가장 적합

원본 README

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

gesture_x_detector

A widget that detects gestures.

Easy to use, lightweight gesture detector for Flutter apps.

Features

  • Detect tap gestures [Tap, DoubleTap, Scale(start, update, end), Long press, Move(start, update, end) and Scroll]
  • All callbacks can be used simultaneously
  • Customize: ignore tap event on double tap, change duration time to detect double tap or long-press

Getting Started

Installation

Add to pubspec.yaml:

dependencies:
    gesture_x_detector:
Example

Checkout the example at https://github.com/taodo2291/xgesture_flutter/tree/master/example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:gesture_x_detector/gesture_x_detector.dart';

void main() {
  runApp(
    MaterialApp(
      home: XGestureExample(),
    ),
  );
}

class XGestureExample extends StatefulWidget {
  @override
  _XGestureExampleState createState() => _XGestureExampleState();
}

class _XGestureExampleState extends State<XGestureExample> {
  String lastEventName = 'Tap on screen';

  @override
  Widget build(BuildContext context) {
    return XGestureDetector(
      child: Material(
        child: Center(
          child: Text(
            lastEventName,
            style: TextStyle(fontSize: 30),
          ),
        ),
      ),
      doubleTapTimeConsider: 300,
      longPressTimeConsider: 350,
      onTap: onTap,
      onDoubleTap: onDoubleTap,
      onLongPress: onLongPress,
      onLongPressEnd: onLongPressEnd,
      onMoveStart: onMoveStart,
      onMoveEnd: onMoveEnd,
      onMoveUpdate: onMoveUpdate,
      onScaleStart: onScaleStart,
      onScaleUpdate: onScaleUpdate,
      onScaleEnd: onScaleEnd,
      bypassTapEventOnDoubleTap: false,
      onLongPressMove: onLongPressMove,
      onScrollEvent: onScrollEvent,
      longPressMaximumRangeAllowed: 25,
    );
  }

  void onScrollEvent(ScrollEvent event) {
    setLastEventName('onLongPressMove');
    print('scrolling - pos: ${event.localPos} delta: ${event.scrollDelta}');
  }

  void onLongPressMove(MoveEvent event) {
    setLastEventName('onLongPressMove');
    print('onMoveUpdate - pos: ${event.localPos} delta: ${event.delta}');
  }

  void onLongPressEnd() {
    setLastEventName('onLongPressEnd');
    print('onLongPressEnd');
  }

  void onScaleEnd() {
    setLastEventName('onScaleEnd');
    print('onScaleEnd');
  }

  void onScaleUpdate(ScaleEvent event) {
    setLastEventName('onScaleUpdate');
    print(
        'onScaleUpdate - changedFocusPoint:  ${event.focalPoint} ; scale: ${event.scale} ;Rotation: ${event.rotationAngle}');
  }

  void onScaleStart(initialFocusPoint) {
    setLastEventName('onScaleStart');
    print('onScaleStart - initialFocusPoint: $initialFocusPoint');
  }

  void onMoveUpdate(MoveEvent event) {
    setLastEventName('onMoveUpdate');
    print('onMoveUpdate - pos: ${event.localPos} delta: ${event.delta}');
  }

  void onMoveEnd(localPos) {
    setLastEventName('onMoveEnd');
    print('onMoveEnd - pos: $localPos');
  }

  void onMoveStart(localPos) {
    setLastEventName('onMoveStart');
    print('onMoveStart - pos: $localPos');
  }

  void onLongPress(TapEvent event) {
    setLastEventName('onLongPress');
    print('onLongPress - pos: ${event.localPos}');
  }

  void onDoubleTap(event) {
    setLastEventName('onDoubleTap');
    print('onDoubleTap - pos: ' + event.localPos.toString());
  }

  void onTap(event) {
    setLastEventName('onTap');
    print('onTap - pos: ' + event.localPos.toString());
  }

  void setLastEventName(String eventName) {
    setState(() {
      lastEventName = eventName;
    });
  }
}

Customize
  • Change DoubleTap and Long press detect
@override
  Widget build(BuildContext context) {
    return XGestureDetector(
      child: child,
      doubleTapTimeConsider: 300,       //customize double tap time
      longPressTimeConsider: 400,       //customize long press time
      longPressMaximumRangeAllowed: 25, //customize the long press behavior, the touch can be move a some pixels (25 is the distanceSquare, that mean we allow move 5 pixels)
    );
  }
  • Ignore Tap in case Double Tap dectected
@override
  Widget build(BuildContext context) {
    return XGestureDetector(
      child: child,
      bypassTapEventOnDoubleTap: true,      // default is false
    );
  }
  • Allow move event after long press event fired without release pointer
@override
  Widget build(BuildContext context) {
    return XGestureDetector(
      child: child,
      bypassMoveEventAfterLongPress: false,      // default is true
    );
  }

Checkout the Canvas playground example at https://github.com/taodo2291/xgesture_flutter/tree/master/example/lib/canvas_playground.dart

Author

Viet Nguyen - taodo2291@gmail.com

카테고리

의존성

의존성 목록 1 개

소스 저장소

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