【发布时间】:2020-12-02 11:40:52
【问题描述】:
在video 中,他们说您可以使用手势识别器在 TextSpan 中创建可点击的链接,但我在 RichText 官方文档和互联网上一般都没有找到示例。有人可以解释一下怎么做吗?
【问题讨论】:
标签: android ios flutter flutter-layout
在video 中,他们说您可以使用手势识别器在 TextSpan 中创建可点击的链接,但我在 RichText 官方文档和互联网上一般都没有找到示例。有人可以解释一下怎么做吗?
【问题讨论】:
标签: android ios flutter flutter-layout
基本上是这样的
RichText(
text: TextSpan(
children: [
TextSpan(text: 'Hello'),
TextSpan(
text: 'World',
recognizer: TapGestureRecognizer()
..onTap = () async {
//Code to launch your URL
}
)
]
)
);
您可以使用URL launcher 来管理链接,如下所示:
const url = 'https://flutter.dev';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
【讨论】: