diff --git a/lib/src/internals.dart b/lib/src/internals.dart index c6e582e..697d520 100644 --- a/lib/src/internals.dart +++ b/lib/src/internals.dart @@ -15,7 +15,6 @@ * limitations under the License. */ -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:xml/xml_events.dart'; @@ -114,16 +113,25 @@ class Parser { if (isLink) { return TextSpan( - style: textStyle, - text: text, - recognizer: TapGestureRecognizer() - ..onTap = () { - if (linksCallback != null) { - linksCallback!(link); - } else { - debugPrint('Add a link callback to visit ${link.toString()}'); - } - }, + children: [ + WidgetSpan( + alignment: PlaceholderAlignment.baseline, + baseline: TextBaseline.alphabetic, + child: Material( + type: MaterialType.transparency, + child: InkWell( + onTap: () { + if (linksCallback != null) { + linksCallback!(link); + } else { + debugPrint('Add a link callback to visit ${link.toString()}'); + } + }, + child: Text(text, style: textStyle), + ), + ), + ), + ], ); } return TextSpan(style: textStyle, text: text); @@ -329,7 +337,10 @@ class Parser { if (event is XmlTextEvent) { final TextSpan currentSpan = _handleText(event.value); - if (currentSpan.text?.isNotEmpty == true) { + if ( + currentSpan.text?.isNotEmpty == true || + currentSpan.children?.isNotEmpty == true + ) { spans.add(currentSpan); } }