Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions lib/src/internals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:xml/xml_events.dart';

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Expand Down