我在标题标签中有一个 CheckboxListTile 和一个小部件。如何为此小部件创建 html 文本(文本 + url)?
My text is: 'Hello <a href="www.aaa.aa">Click here</a>!'
我尝试过:flutter_html:^0.10.4
没有运气
谢谢
最佳答案
编辑: 您可以尝试link: ^1.1.0
import 'package:link/link.dart';
...
Link(
child: Text('This is a link to Flutter', style: TextStyle(
decoration: TextDecoration.underline, // add add underline in text
),),
url: 'https://google.com',
onError: _showErrorSnackBar,
),
void _showErrorSnackBar() {
Scaffold.of(context).showSnackBar(
SnackBar(
content: Text('Oops... the URL couldn\'t be opened!'),
),
);
}
...
输出:
你试过吗url_launcher ,
RaisedButton(
onPressed: _launchURL,
child: Text('Text'),
),
_launchURL() async {
const url = 'https://flutter.dev';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
您也可以尝试linkify
linkify("Made by https://cretezy.com");
关于Flutter 将可点击的链接/url 添加到 CheckboxListTile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59156620/