我正在开发一个应用程序,允许用户建立他们的健身房平面图,并将按钮放置在机器将在的地方。
我目前正在使用一个交互式查看器来显示平面布置图。我需要的功能,以创建一个按钮小部件的“用户”长按。
下面是我的当前代码和onLongPressEnd
类。
Padding(
padding: const EdgeInsets.symmetric(vertical: 1),
child: Center(
child: GestureDetector(
onLongPressEnd: ((details) => {
//Code to create button goes here
}),
child: InteractiveViewer(
minScale: 1,
maxScale: 2,
child: Stack(
children: [
Image.asset(
'Assets/Lift View Images/room_layout_1.png'),
);
有人在互联网上发布了一个几乎相同的问题,并创建了一个完整的解决方案,问题是,因为他的解决方案,InteractiveViewer
小部件已被添加,所以他的所有代码是过时的,不能复制到一个较新的版本。
https://medium.com/@alexander.arendar/dragging-zooming-and-placing-object-on-indoor-map-with-flutter-67667ef415ec
总之,我需要的功能,为用户创建预定义的小部件按下页面。
完整代码https://github.com/CokeMango/mapview_iteration_1.git
我花了几个小时来理解这个文档解决方案https://medium.com/@alexander.arendar/dragging-zooming-and-placing-object-on-indoor-map-with-flutter-67667ef415ec,但始终没有弄清楚如何用交互式查看器小部件来实现它,而且作为Flutter的新手,我不能完全复制它。
我也在网上搜索了一段时间,最多我找到了我已经拥有的,那是一个没有任何功能的可缩放可滚动图像查看器。
1条答案
按热度按时间zf9nrax11#
这里你可以看到两种方法:
FloorPlanWithFixedButtons
添加固定大小的“按钮”(无论InteractiveViewer
当前使用的缩放因子是什么),而FloorPlanWithScaledButtons
直接向InteractiveViewer
添加“按钮”,以便在放大/缩小时自动缩放如果您需要可拖动的“按钮”,请选中
FloorPlanWithScaledDraggableButtons
小部件带固定按钮的楼层平面图
带缩放按钮的平面布置图
带缩放可拖动按钮的楼层平面