tezvyn:

What gesture conflict exists in a scrollable list with horizontal swipes?

AI-drafted, machine-checkedSource: docs.flutter.devintermediate

Tests Flutter's gesture arena and slop disambiguation. Diagonal motion triggers both vertical scroll and horizontal swipe; the axis whose delta exceeds touch slop first wins the arena. Red flag: claiming Flutter blocks inner gestures or fires both at once.

WHAT THIS TESTS: This question probes whether you understand Flutter's gesture disambiguation architecture beyond simple widget composition. Specifically, it checks if you know that competing gesture recognizers do not automatically block each other but instead participate in a gesture arena managed by the GestureArenaManager. The interviewer wants to see that you recognize the geometric ambiguity when a user drags diagonally inside a vertically scrolling list that also supports horizontal swipes, and that you can explain the resolution mechanism in terms of touch slop, primary axes, and arena acceptance or rejection.

A GOOD ANSWER COVERS: First, name the conflict explicitly: a diagonal drag creates ambiguity because the pointer delta can exceed the touch slop on both the vertical and horizontal axes, so the framework cannot immediately know whether the user intends to scroll the list or swipe the item. Second, describe the arena: both the VerticalDragGestureRecognizer from the scrollable and the HorizontalDragGestureRecognizer from the item enter the same gesture arena for that pointer. Third, explain slop-based resolution: each recognizer tracks pointer deltas and waits until the motion clearly favors its primary axis before accepting; the first recognizer to accept wins the arena, and the framework instructs the losers to reject. Fourth, mention practical tuning: you can adjust behavior through dragStartBehavior, gesture settings, or by wrapping the child in a GestureDetector with a custom gesture arena strategy if the default slop thresholds feel wrong.

COMMON WRONG ANSWERS: A dangerous red flag is claiming that the parent scrollable always wins by default or that Flutter uses a hardcoded z-index-like layering to suppress inner gestures. Another weak answer is saying both gestures fire at the same time and the developer must manually cancel one. Some candidates incorrectly blame the hit-test phase alone; while hit-testing determines which recognizers are invited into the arena, it does not resolve the conflict once the pointer moves.

LIKELY FOLLOW-UPS: The interviewer might ask how you would implement a custom swipe action if the default Dismissible behavior is insufficient, which leads to writing a RawGestureDetector with a custom GestureRecognizer. They might also ask how platform differences affect slop values, or how to make the horizontal swipe win more aggressively by reducing its slop or delaying the scroll recognizer. A senior candidate should also be ready to discuss the difference between the gesture arena and pointer event bubbling in the render tree.

ONE CONCRETE EXAMPLE: Imagine a ListView of email threads where each row can be swiped horizontally to archive. If the user drags their thumb at a forty-five degree angle, both the ListView's VerticalDragGestureRecognizer and the row's HorizontalDragGestureRecognizer receive the pointer. During the initial few pixels both recognizers remain in the arena. Once the horizontal delta exceeds eighteen logical pixels while the vertical delta stays under the scroll threshold, the horizontal recognizer accepts and the ListView's recognizer rejects, locking the gesture to the swipe. If the vertical delta exceeds its threshold first, the scrollable accepts and the row never opens.

Read the original → docs.flutter.dev

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.