if (resamplingEnabled) { _resampler.addOrDispatch(event); _resampler.sample(samplingOffset, _samplingClock); return; }
// Stop resampler if resampling is not enabled. This is a no-op if // resampling was never enabled. _resampler.stop(); _handlePointerEventImmediately(event); }
void _handlePointerEventImmediately(PointerEvent event) { HitTestResult? hitTestResult; if (event is PointerDownEvent || event is PointerSignalEvent || event is PointerHoverEvent || event is PointerPanZoomStartEvent) { hitTestResult = HitTestResult(); //开始碰撞检测 先调用RenderBinding中的 再调用GestureBinding中的 hitTest(hitTestResult, event.position); if (event is PointerDownEvent || event is PointerPanZoomStartEvent) { _hitTests[event.pointer] = hitTestResult; } } elseif (event is PointerUpEvent || event is PointerCancelEvent || event is PointerPanZoomEndEvent) { //复用机制,抬起或取消,不用hitTest,移除 hitTestResult = _hitTests.remove(event.pointer); } elseif (event.down || event is PointerPanZoomUpdateEvent) { hitTestResult = _hitTests[event.pointer]; } if (hitTestResult != null || event is PointerAddedEvent || event is PointerRemovedEvent) { //分发事件 dispatchEvent(event, hitTestResult); } }
_GestureArena:GestureArenaManager 内的竞技场,内部持参与竞技的 members 列表,官方对这个竞技场的解释是: 如果一个手势试图在竞技场开放时(isOpen=true)获胜,它将成为一个带有“渴望获胜”的属性的对象。当竞技场关闭(isOpen=false)时,竞技场将寻找一个“渴望获胜”的对象成为新的参与者,如果这时候刚好只有一个,那这一个参与者将成为这次竞技场胜利的青睐存在。