草庐IT

gesturedetector

全部标签

flutter - 覆盖子 GestureDetectors 的 GestureDetector?

有没有办法让GestureDetector覆盖所有子GestureDetectors的功能?我有一个复杂的小部件,我希望能够轻松地在较高级别覆盖它的所有行为。例如,将免费用户锁定在功能之外。 最佳答案 要暂时禁用所有子手势检测器,请使用IgnorePointer小部件:@overrideWidgetbuild(BuildContextcontext){boolignoreChildGestures=true;returnGestureDetector(onTap:(){print('parenttapped');},child:Ig

dart - GestureDetector 内的 ScrollView : Dispatch Touch Events

我有一个GestureDetector负责上下拖动容器以更改高度。容器内容可能太长,必须滚动内容。我不知道如何将触摸事件分派(dispatch)到正确的组件,我尝试使用IgnorePointer并更改ignoring属性。class_SlideSheetStateextendsStatebool_ignoreScrolling=true;GestureDetector(onVerticalDragUpdate:(DragUpdateDetailsdetails){if(isDraggedUp){setState((){_ignoreScrolling=false});}//update

dart - GestureDetector 内的 ScrollView : Dispatch Touch Events

我有一个GestureDetector负责上下拖动容器以更改高度。容器内容可能太长,必须滚动内容。我不知道如何将触摸事件分派(dispatch)到正确的组件,我尝试使用IgnorePointer并更改ignoring属性。class_SlideSheetStateextendsStatebool_ignoreScrolling=true;GestureDetector(onVerticalDragUpdate:(DragUpdateDetailsdetails){if(isDraggedUp){setState((){_ignoreScrolling=false});}//update

button - 我怎样才能实现类似 "onContinuousPress"的行为?

假设我的Flutter应用中有这个按钮:FloatingActionButton(backgroundColor:Theme.of(context).primaryColor,child:Icon(Icons.arrow_upward),onPressed:_someAction,);我希望只要我的手指敲击按钮,_someAction()就会被执行(即,如果我连续敲击T秒_someAction()应该执行N次,其中N=(int)(60/T+1))我调查了GestureDetector但在那里找不到我需要的东西。例如,我需要这个来增加/减少一些int值...

button - 我怎样才能实现类似 "onContinuousPress"的行为?

假设我的Flutter应用中有这个按钮:FloatingActionButton(backgroundColor:Theme.of(context).primaryColor,child:Icon(Icons.arrow_upward),onPressed:_someAction,);我希望只要我的手指敲击按钮,_someAction()就会被执行(即,如果我连续敲击T秒_someAction()应该执行N次,其中N=(int)(60/T+1))我调查了GestureDetector但在那里找不到我需要的东西。例如,我需要这个来增加/减少一些int值...

android - flutter 执行方法只要按下按钮

我想在用户按下按钮时执行一个方法。在伪代码中:while(button.isPressed){executeCallback();}换句话说,executeCallback方法应该在用户按下按钮时重复触发,并在释放按钮时停止触发。我怎样才能在Flutter中实现这一点? 最佳答案 使用Listener和有状态的小部件。我还在每个循环之后引入了轻微的延迟:import'dart:async';import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classM

android - flutter 执行方法只要按下按钮

我想在用户按下按钮时执行一个方法。在伪代码中:while(button.isPressed){executeCallback();}换句话说,executeCallback方法应该在用户按下按钮时重复触发,并在释放按钮时停止触发。我怎样才能在Flutter中实现这一点? 最佳答案 使用Listener和有状态的小部件。我还在每个循环之后引入了轻微的延迟:import'dart:async';import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classM

dart - GestureDetector onTap 卡片

newExpanded(child:_searchResult.length!=0||controller.text.isNotEmpty?newListView.builder(itemCount:_searchResult.length,itemBuilder:(context,inti){returnnewCard(child:newColumn(mainAxisSize:MainAxisSize.min,children:[newRow(children:[//newGestureDetector(),newContainer(width:45.0,height:45.0,de

dart - GestureDetector onTap 卡片

newExpanded(child:_searchResult.length!=0||controller.text.isNotEmpty?newListView.builder(itemCount:_searchResult.length,itemBuilder:(context,inti){returnnewCard(child:newColumn(mainAxisSize:MainAxisSize.min,children:[newRow(children:[//newGestureDetector(),newContainer(width:45.0,height:45.0,de

flutter - 在同一页面上有 2 个具有相同手势的手势检测器

我们正在构建一个包含2个容器的页面,一个是覆盖整个屏幕的大容器,另一个是大容器内的小容器。当用户触摸小容器内部并移动手指时,它应该平移小容器。当他们从小容器中滑出时,它应该移动大容器(就像Tinder中的卡片)。问题是,大容器总是在小容器获得平移事件之前获得滑动事件。有没有办法使用手势事件,以便它们不会发送到其他组件?我看过有关GestureArena的文档,但没有找到有关其工作原理的任何示例。有没有办法强制组件总是赢得竞技场(或总是输)?编辑:为清楚起见重新表述。 最佳答案 非常直接的解决方案:对于您的顶级GestureDetec