From 667489693da823cac9bc47892dfafc249ef649ae Mon Sep 17 00:00:00 2001 From: Bruce Date: Fri, 23 May 2025 13:07:08 -0600 Subject: [PATCH 1/2] Add visual feedback when link is tapped - Using InkWell for feedback - Wrapped in Material so "splash" will always be visible - WidgetSpan wrapped by TextSpan as that is what the function needs to return - Added logic to also display the span if it has children --- lib/src/internals.dart | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/src/internals.dart b/lib/src/internals.dart index c6e582e..9673651 100644 --- a/lib/src/internals.dart +++ b/lib/src/internals.dart @@ -114,16 +114,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 +338,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); } } From 57af648f5350c402f85b59826b51ff9b8db33f69 Mon Sep 17 00:00:00 2001 From: Bruce Date: Fri, 23 May 2025 15:15:20 -0600 Subject: [PATCH 2/2] Remove (recently) unnecessary import --- lib/src/internals.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/internals.dart b/lib/src/internals.dart index 9673651..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';