簡體   English   中英

Flutter 將可點擊的鏈接/網址添加到 CheckboxListTile

[英]Flutter add clickable link/url to a CheckboxListTile

我在標題標簽中有一個 CheckboxListTile 和一個小部件。 如何為此小部件創建 html 文本(文本 + url)?

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

我試過這個: flutter_html:^0.10.4

沒有運氣

謝謝

編輯:您可以嘗試鏈接:^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_linkify

您需要用Linkify小部件替換Text

使用此插件,您的代碼可能如下所示:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM