diff --git a/lib/html_parser.dart b/lib/html_parser.dart
index bfdd06ab77..919ff36c0d 100644
--- a/lib/html_parser.dart
+++ b/lib/html_parser.dart
@@ -336,37 +336,46 @@ class HtmlParser extends StatelessWidget {
);
}
} else if (tree is InteractableElement) {
+ InlineSpan addTaps(InlineSpan childSpan, TextStyle childStyle) {
+ if (childSpan is TextSpan) {
+ return TextSpan(
+ text: childSpan.text,
+ children: childSpan.children
+ ?.map((e) => addTaps(e, childStyle.merge(childSpan.style)))
+ ?.toList(),
+ style: newContext.style.generateTextStyle().merge(
+ childSpan.style == null
+ ? childStyle
+ : childStyle.merge(childSpan.style)),
+ semanticsLabel: childSpan.semanticsLabel,
+ recognizer: TapGestureRecognizer()
+ ..onTap = () => onLinkTap?.call(tree.href),
+ );
+ } else {
+ return WidgetSpan(
+ child: RawGestureDetector(
+ gestures: {
+ MultipleTapGestureRecognizer:
+ GestureRecognizerFactoryWithHandlers<
+ MultipleTapGestureRecognizer>(
+ () => MultipleTapGestureRecognizer(),
+ (instance) {
+ instance..onTap = () => onLinkTap?.call(tree.href);
+ },
+ ),
+ },
+ child: (childSpan as WidgetSpan).child,
+ ),
+ );
+ }
+ }
+
return TextSpan(
children: tree.children
.map((tree) => parseTree(newContext, tree))
.map((childSpan) {
- if (childSpan is TextSpan) {
- return TextSpan(
- text: childSpan.text,
- children: childSpan.children,
- style: (childSpan.style ?? TextStyle())
- .merge(newContext.style.generateTextStyle()),
- semanticsLabel: childSpan.semanticsLabel,
- recognizer: TapGestureRecognizer()
- ..onTap = () => onLinkTap?.call(tree.href),
- );
- } else {
- return WidgetSpan(
- child: RawGestureDetector(
- gestures: {
- MultipleTapGestureRecognizer:
- GestureRecognizerFactoryWithHandlers<
- MultipleTapGestureRecognizer>(
- () => MultipleTapGestureRecognizer(),
- (instance) {
- instance..onTap = () => onLinkTap?.call(tree.href);
- },
- ),
- },
- child: (childSpan as WidgetSpan).child,
- ),
- );
- }
+ return addTaps(childSpan,
+ newContext.style.generateTextStyle().merge(childSpan.style));
}).toList() ??
[],
);