简体   繁体   中英

Flutter add clickable link/url to a CheckboxListTile

I have a CheckboxListTile and a widget in the title tag. How can I create a html text (text + url) to this widget?

My text is: 'Hello <a href="www.aaa.aa">Click here</a>!'

I tried this: flutter_html: ^0.10.4

with no luck

Thanks

Edit: You can try 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!'),
      ),
    );
  }
...

Output:

在此处输入图片说明


Have you tried 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';
  }

You can also try linkify

linkify("Made by https://cretezy.com");

You could try flutter_linkify .

You need to replace Text with Linkify widget.

With this plugin you code might look like this:

Linkify(
  onOpen: (link) => print("Clicked ${link.url}!"),
  text: "Made by https://cretezy.com",
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM