gpt4 book ai didi

Flutter 将可点击的链接/url 添加到 CheckboxListTile

转载 作者:行者123 更新时间:2023-12-02 03:05:20 27 4
gpt4 key购买 nike

我在标题标签中有一个 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!'),
),
);
}
...

输出:

enter image description here


你试过吗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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com