Flutter `GestureRecognizer` that only responds to two-finger gestures

  Kiến thức lập trình

How do I create a GestureRecognizer in Flutter that only responds to two-finger gestures, and passes single-finger gestures on to other widgets in the arena?

In my Flutter app, I have a GoogleMap widget inside a SingleChildScrollView. The GoogleMap widget takes a gestureRecognizers parameter which I have set to the following, otherwise it is not even possible to interact with the map (the ScrollView gets all the touch events, at least 95% of the time…)

  gestureRecognizers: const {
    Factory<OneSequenceGestureRecognizer>(
      EagerGestureRecognizer.new,
    ),
  },

With this GestureRecognizer, the Google Maps widget responds to single-finger gestures (pan) and two-finger gestures (zoom/pan). I want the widget to respond only two-finger gestures, because currently dragging with one finger on the map widget interrupts the user’s ability to scroll the view up or down. So I want single-finger gestures to go to the ScrollView, and two-finger gestures to go to Google Maps. (The Google Maps web widget requires a two-finger gesture for pan, for the same reason…)

How do I replace EagerGestureRecognizer with a gesture recognizer that causes Maps to only pan if two fingers are down, otherwise to pass the single-finger gesture through to the scroll view?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT