Open RegisSaffi opened 3 years ago
I'd be interested in this too. For now I'm wrapping the CanvasTouchDetector in an IgnorePointer widget and toggling it on and off based on the user's interaction. I wrote an article on it here.
Yes please! +1 on this feature. Still trying to find a workaround here.
@jtmuller5 - can you please expand on your approach? I appreciate the article but i have questions in the details of making touchable work within the interactive viewer. I have tried to implement as described just drawing circles - none of the SVG stuff you describe.
My widget tree is something like:
Within DrawTouchyCircle paint method I pass the canvas to a TouchyCanvas. I have a variable passed around via provider to keep track of ignoreInteractivity for the IgnorePointer "ignoring" field.
I interpreted as follows from the article you linked. Turn it on when onInteractionStart is called in the InteractiveViewer (set ignoreInteractivity to true) Turn it off when the onInteractionEnd is called in the InteractiveViewer (set to false) Turn it off when the user taps on the InteractiveViewer (set to false. where does this occur? - in TouchyCanvas onTap? in a higher level gesture detector?) Turn it on when onPanUpdate is called in your TouchyCanvas (set to true) Turn it on when onPanStart is called in your TouchyCanvas (set to true) Turn it off when onTapUp is called in your TouchyCanvas (set to false)
literally came here about the same issue. For some reason flutter's built in hitTest method on CustomPainter just returns null, and doesnt seem to have the intended functionality.
So after digging through the source code in the library , disabling onPanStart , onPanUpdate, onPanDown fixes it for the timing. Inherently issue #2 gave some hints. @nateshmbhat is there a possibility where certain gesture behaviours caught by the gesture detector will be passed up to the parent widget when no call back is assigned?
In case anyone else has this issue, I've fixed it by passing the gesturesToOverride
prop to CanvasTouchDetector
:
InteractiveViewer(
child: CanvasTouchDetector(
gesturesToOverride: const [
// add here the events your custom paint should react to...
GestureType.onTapDown,
],
builder: (context) => CustomPaint(
size: MediaQuery.of(context).size,
painter: MyPainter(context),
),
),
)
I love Touchable, but ever since i wanted to use it with new InteractiveViewer widget introduced in Flutter 1.20, the interactiveViewer can't listen to drag or scale or any event, is it possible to make it work together?