Show tooltip for links
continuous-integration/drone/pr Build is pending
Details
continuous-integration/drone/pr Build is pending
Details
This commit is contained in:
parent
1700306c78
commit
ca44fd798c
|
@ -353,20 +353,24 @@ TextSpan buildTextSpan(
|
|||
(element) {
|
||||
if (element is LinkableElement) {
|
||||
if (useMouseRegion) {
|
||||
return LinkableSpan(
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
inlineSpan: TextSpan(
|
||||
text: element.text,
|
||||
style: linkStyle,
|
||||
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
|
||||
),
|
||||
);
|
||||
return TooltipSpan(
|
||||
message: element.url,
|
||||
inlineSpan: LinkableSpan(
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
inlineSpan: TextSpan(
|
||||
text: element.text,
|
||||
style: linkStyle,
|
||||
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
|
||||
),
|
||||
));
|
||||
} else {
|
||||
return TextSpan(
|
||||
text: element.text,
|
||||
style: linkStyle,
|
||||
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
|
||||
);
|
||||
return TooltipSpan(
|
||||
message: element.url,
|
||||
inlineSpan: TextSpan(
|
||||
text: element.text,
|
||||
style: linkStyle,
|
||||
recognizer: onOpen != null ? (TapGestureRecognizer()..onTap = () => onOpen(element)) : null,
|
||||
));
|
||||
}
|
||||
} else {
|
||||
return TextSpan(
|
||||
|
@ -378,3 +382,18 @@ TextSpan buildTextSpan(
|
|||
).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
// Show a tooltip over an inlined element in a Rich Text widget.
|
||||
class TooltipSpan extends WidgetSpan {
|
||||
TooltipSpan({
|
||||
required String message,
|
||||
required InlineSpan inlineSpan,
|
||||
}) : super(
|
||||
child: Tooltip(
|
||||
message: message,
|
||||
child: Text.rich(
|
||||
inlineSpan,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue