我正在使用 flutter_markdown 库来显示 markdown 文本,对我来说,每次超链接都以默认的颤动蓝色显示,我尝试更改 ThemeData 应用程序颜色,但没有帮助,基本上我需要的是将超链接的颜色从蓝色更改为绿色并添加下划线。
这可能吗?如果没有,请建议一些替代方法如何实现它
我正在使用此代码:
_showMarkdownTestModal() {
var testMarkdown = '[flutter_markdown](https://github.com/DavBfr/flutter_markdown)';
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
builder: (builder) {
return FractionallySizedBox(
heightFactor: 0.1,
child: Center(
child: MarkdownBody(
data: testMarkdown,
onTapLink: (text, url, title) {
if (url != null) {
_launchURL(Uri.parse(url));
}
},
)));
});
}
预先感谢您的帮助
就像这样:
MarkdownBody(
styleSheet: MarkdownStyleSheet(
a: const TextStyle(
color: Colors.red,
decoration: TextDecoration.underline,
),
// ...
),
// ...
);
虽然接受的答案适用于文本颜色,但它忽略了下划线颜色。如果你想在那里使用相同的颜色,也可以这样声明:
TextStyle(
color: Colors.red,
decoration: TextDecoration.underline,
decorationColor: Colors.red,
)