How to call the onTap method of a built GestureDetector?

Viewed 23

I am using the flutter package AnimatedTextKit which displays some animated text. (https://pub.dev/packages/animated_text_kit)

An AnimatedTextKit is a StatefulWidget and builds a GestureDetector :

@override Widget build(BuildContext context) {
final completeText = _currentAnimatedText.completeText(context);
return GestureDetector(
  behavior: HitTestBehavior.opaque,
  onTap: _onTap,
  child: _isCurrentlyPausing || !_controller.isAnimating
      ? completeText
      : AnimatedBuilder(
          animation: _controller,
          builder: _currentAnimatedText.animatedBuilder,
          child: completeText,
        ),
);
}

I wrap the AnimatedTextKit into a Card, and also show a yellow triangle at the bottom of the Card when the text is fully displayed :

Card containing an AnimatedTextKit

When I tap on the text : it's fine since the AnimatedTextKit GestureDetector detects the tap. But when I tap on the yellow triangle just below, because I tap outside the AnimatedTextKit widget, the tap is not detected, which is normal.

Is there a clean way to make a tap made anywhere on the Card be interpreted as a tap on the AnimatedTextKit ?

I have looked at these answers : How to pass Taps to widgets below the top widget? and How do I programmatically simulate onTap on a button in Flutter? but I feel like I'm not able to apply the proposed solutions since I cannot modify the AnimatedTextKit library code.

0 Answers
Related