Android development, some system functions do not meet our development needs, may go back to look at the source code, consider how to override the implementation, or consider directly copy the source code, their own implementation, of course, if the code is very complex, then copy is not a wise choice.
Based on the above, one of the ills of the Flutter is that the face interface of the slide control (if not set to physics) can be clicked and the parent control starts to slide, there will be a flutter
Problem code in acceptGesture (DragGestureRecognizer)
_state = _DragState.accepted;
/// 1
final Offset delta = _pendingDragOffset;
/// 2
final Duration timestamp = _lastPendingEventTimestamp;
/// 3
_pendingDragOffset = Offset.zero;
Copy the code
The above code is executed when we start to drag, _pendingDragOffset is used to determine whether the drag has started, and _pendingDragOffset >kTouchSlop is used to call acceptGesture to confirm the start of the drag, At this time, _pendingDragOffset is greater than kTouchSlop by at least 18px. This value is reset at 3, and delta at 1 is the initial offset, so it causes this jitter
_state = _DragState.accepted;
/// 1
final Offset delta = Offset.zero;
/// 2
final Duration timestamp = _lastPendingEventTimestamp;
/// 3
_pendingDragOffset = Offset.zero;
Copy the code
Delta is set to 0
conclusion
The change to the Flutter source code takes effect immediately, and the change is minimal even for multiple developers. And can change the system code directly!! Can change the system code directly!! Can change the system code directly!! So the extent to which Flutter can be extended is really hard to imagine (at least until the underlying code of Flutter was written into Android…)