feat: Update scale event with custom recognizer
Description
Currently flame handle scale input events in a very hacky way, by getting the drag gesture recognizer data and recomputing the data for the scale gesture. This has multiple issues :
- Recompute already computed stuff like rotation and scale factor -> inefficient
- Make the code difficult to understand, had to introduce hard dependencies between scale and drag dispatcher
- Limits the allowed multi drag gestures : those looking like scale gestures simply would not register as such but only as scale
This PR aims to fix all those issues by introducing a new gesture recognizer, which is basically just a mix of ScaleGestureRecognizer and immediateMultiDragGestureRecognizer, allowing pointers to be used for both gestures without competing. I used the existing flutter code to write it.
I modified a bit ScaleCallbacks and DragCallbacks, so they use their original dispatcher if there is only one type of them (it's a bit more efficient), and so they upgrade to using MultiDragScaleDispatcher if both mixins are mounted. Transition between the two is smooth as the old dispatcher wait for all gestures it started to finish before removing itself.
Checklist
- [x] I have followed the Contributor Guide when preparing my PR.
- [x] I have updated/added tests for ALL new/updated/fixed functionality.
- [ ] I have updated/added relevant documentation in
docsand added dartdoc comments with///. - [x] I have updated/added relevant examples in
examplesordocs.
I wonder if gesture_input.md should be updated
Breaking Change?
- [ ] Yes, this PR is a breaking change.
- [x] No, this PR is not a breaking change.
Related Issues
I believe it Closes #2635