void updateDrag(Offset globalPosition) { this._lastOffset = globalPosition - this.dragStartPoint; this._entry.markNeedsBuild(); HitTestResult result = new HitTestResult(); WidgetsBinding.instance.hitTest(result, globalPosition + this.feedbackOffset); List <_DragTargetState <T> > targets = this._getDragTargets(result.path.ToList()); bool listsMatch = false; if (targets.Count >= this._enteredTargets.Count && this._enteredTargets.isNotEmpty()) { listsMatch = true; List <_DragTargetState <T> > .Enumerator iterator = targets.GetEnumerator(); for (int i = 0; i < this._enteredTargets.Count; i++) { iterator.MoveNext(); if (iterator.Current != this._enteredTargets[i]) { listsMatch = false; break; } } } if (listsMatch) { return; } this._leaveAllEntered(); _DragTargetState <T> newTarget = null; foreach (var target in targets) { this._enteredTargets.Add(target); if (target.didEnter(this)) { newTarget = target; break; } } this._activeTarget = newTarget; }
void finishDrag(_DragEndKind endKind, Velocity velocity = null) { bool wasAccepted = false; if (endKind == _DragEndKind.dropped && this._activeTarget != null) { this._activeTarget.didDrop(this); wasAccepted = true; this._enteredTargets.Remove(this._activeTarget); } this._leaveAllEntered(); this._activeTarget = null; this._entry.remove(); this._entry = null; if (this.onDragEnd != null) { this.onDragEnd(velocity == null ? Velocity.zero : velocity, this._lastOffset, wasAccepted); } }