Add Pixel eye logic. Can comparison with 2 image and monitor
This commit is contained in:
1 parent
da7cb5ea23
commit
e8bd345be6
22 files changed
+993
-73
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DraggableArea extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const DraggableArea({
|
||||
Key? key,
|
||||
required this.child,
|
||||
this.moveChanged,
|
||||
this.dx = 0,
|
||||
this.dy = 0,
|
||||
}) : super(key: key);
|
||||
final Function(double dx, double dy)? moveChanged;
|
||||
final double dx;
|
||||
final double dy;
|
||||
|
||||
@override
|
||||
State<DraggableArea> createState() => _DraggableAreaState();
|
||||
}
|
||||
|
||||
class _DraggableAreaState extends State<DraggableArea> {
|
||||
late double left = widget.dx;
|
||||
late double top = widget.dy;
|
||||
|
||||
double? first;
|
||||
double? end;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
left: left,
|
||||
top: top,
|
||||
child: Draggable(
|
||||
feedback: widget.child,
|
||||
childWhenDragging: const SizedBox.shrink(),
|
||||
onDragUpdate: (u) => onUpdate(u),
|
||||
onDragEnd: (detail) => onEnd(detail.offset),
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void onEnd(Offset offset) {
|
||||
left = offset.dx;
|
||||
top = top + (end ?? 0) - (first ?? 0);
|
||||
first = null;
|
||||
end = null;
|
||||
widget.moveChanged?.call(left, top);
|
||||
}
|
||||
|
||||
onUpdate(DragUpdateDetails u) {
|
||||
first ??= u.globalPosition.dy;
|
||||
end = u.globalPosition.dy;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user