Skip to content

Flutter Package for Gesture Trajectory Interaction using 'One Dollar Unistroke Recognizer' | 结合“1$轨迹识别算法”的移动端触摸手势SDK

License

Notifications You must be signed in to change notification settings

adaelixir/flutter-onedollar-handtrace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter OneDollar HandTrace

Flutter OneDollar HandTrace 是一个用于手势轨迹识别的 Flutter 包,基于 $1 Unistroke Recognizer 算法。这个包允许您在 Flutter 应用中轻松集成手势识别功能

a. 实时手势轨迹绘制
b. 基于 $1 Unistroke Recognizer 算法的手势识别
c. 自定义识别结果展示(弹出窗口和提示栏)
d. 支持单指绘制和双指缩放
e. 可扩展的模板系统,支持添加自定义手势

Wakeup Circle Check Star

安装和使用方法

将以下行添加到您的 pubspec.yaml 文件中:

dependencies:
  flutter_onedollar_handtrace: ^0.1.2

然后运行:

flutter pub get

导入包:

import 'package:flutter_onedollar_handtrace/flutter_onedollar_handtrace.dart';

创建一个 GestureService 实例:

final gestureService = GestureService(
  context: context,
  callback: (name, score) {
    print('Recognized gesture: $name with score: $score');
  },
  drawingView: DrawingView(key: GlobalKey<DrawingViewState>()),
);

在您的 widget 树中使用 GestureService:

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: gestureService.buildGestureDetector(context),
  );
}

功能扩展

a. 自定义绘制样式

DrawingView(
  key: GlobalKey<DrawingViewState>(),
  lineColor: Colors.blue,
  strokeWidth: 2.0,
)

b. 自定义识别结果的展示方式

GestureService(
  // ...
  popupBuilder: (context, name, score) {
    // 自定义弹出窗口逻辑
  },
  snackbarBuilder: (context, message) {
    // 自定义提示栏逻辑
  },
)

c. 向识别器添加自定义手势模板

final recognizer = TrajectoryRecognizer();
recognizer.addTemplate(Template('自定义手势', [Point(0, 0), Point(1, 1), ...]));

About

Flutter Package for Gesture Trajectory Interaction using 'One Dollar Unistroke Recognizer' | 结合“1$轨迹识别算法”的移动端触摸手势SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages