implement change cursor to SystemMouseCursors.click when hovering a link styled text (#437)

Co-authored-by: KhanhNgocNguyen <khanhnguyen2@teqnological.asia>
pull/451/head
Khánh Nguyễn 3 years ago committed by GitHub
parent 3a0add9a4c
commit 0b1e0f2179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      lib/src/widgets/text_line.dart

@ -184,6 +184,7 @@ class TextLine extends StatelessWidget {
final style = textNode.style;
var res = const TextStyle(); // This is inline text style
final color = textNode.style.attributes[Attribute.color.key];
var hasLink = false;
<String, TextStyle?>{
Attribute.bold.key: defaultStyles.bold,
@ -203,6 +204,9 @@ class TextLine extends StatelessWidget {
res = _merge(res.copyWith(decorationColor: textColor),
s!.copyWith(decorationColor: textColor));
} else {
if (k == Attribute.link.key) {
hasLink = true;
}
res = _merge(res, s!);
}
}
@ -252,6 +256,13 @@ class TextLine extends StatelessWidget {
}
res = _applyCustomAttributes(res, textNode.style.attributes);
if (hasLink && readOnly) {
return TextSpan(
text: textNode.value,
style: res,
mouseCursor: SystemMouseCursors.click,
);
}
return TextSpan(text: textNode.value, style: res);
}

Loading…
Cancel
Save