最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

url - Hyperlink href preview in flutter - Stack Overflow

programmeradmin1浏览0评论

In react or html when you hover over a link element like this:

Example Link

The browser shows a tooltip of the url at the bottom left of the browser.

Is there any way to achieve this in flutter?

I tried this in flutter and the url tooltip never shows up at the bottom left:

import 'package:flutter/material.dart';
import 'package:flutter_custom_tabs/flutter_custom_tabs.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
    
class Link extends StatelessWidget {
  const Link({
    super.key,
      required this.urlLabel,
      required this.url,
  });
    
  final String urlLabel;
  final String url;
    
  Future<void> _launchUrl(String url) async {
    final Uri uri = Uri.parse(url);
    launchUrl(uri);
  }
    
  @override
  Widget build(BuildContext context) {
    return MarkdownBody(
      data: '[$urlLabel]($url)',
      onTapLink: (text, href, title) async {
        if (href != null) {
          await _launchUrl(href);
        }
      },
    );
  }
}
发布评论

评论列表(0)

  1. 暂无评论