如何制作颤振超链接?

发布于 2025-01-10 16:37:58 字数 627 浏览 0 评论 0原文

如何在 flutter 中创建电子邮件超链接? /////////////////////////////////////////////////////////// ///////////////////

import 'package:flutter/material.dart';


showAlertDialog(BuildContext context) {
  AlertDialog alert = const AlertDialog(
    title: Text('Contact us'),
    content: Text(
        'Please contact our team via email: **[email protected]**', //hyperlink
    ),
  );
  showDialog(
    context: context,
    builder: (BuildContext context){
      return alert;
    },
  );
}

how do I create an email hyperlin in flutter?
////////////////////////////////////////////////////////////

import 'package:flutter/material.dart';


showAlertDialog(BuildContext context) {
  AlertDialog alert = const AlertDialog(
    title: Text('Contact us'),
    content: Text(
        'Please contact our team via email: **[email protected]**', //hyperlink
    ),
  );
  showDialog(
    context: context,
    builder: (BuildContext context){
      return alert;
    },
  );
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

愁以何悠 2025-01-17 16:37:59

Flutter 本身支持富文本,但我认为这对你来说还不够。您可以使用这个包进行操作,并且您可以直接处理您的链接。(如果您愿意的话)应该是为链接编写自定义操作,例如下面的代码)

Widget html = Html(
  data: """<p>
   Linking to <a href='https://github.com'>websites</a> has never been easier.
  </p>""",
  onLinkTap: (String? url, RenderContext context, Map<String, String> attributes, dom.Element? element) {
    //open URL in webview, or launch URL in browser, or any other logic here
  }
);

Flutter natively support Rich text, but I think doesn't enough for you. You can use this package for your operations, and you can handle your link directly.(If you want you should be to write custom action for links for instance below code)

Widget html = Html(
  data: """<p>
   Linking to <a href='https://github.com'>websites</a> has never been easier.
  </p>""",
  onLinkTap: (String? url, RenderContext context, Map<String, String> attributes, dom.Element? element) {
    //open URL in webview, or launch URL in browser, or any other logic here
  }
);
韶华倾负 2025-01-17 16:37:59
Uri emailLanuch = Uri(
    scheme: 'mailto',
    path: "[email protected]",
  );
  showAlertDialog(BuildContext context) {

    AlertDialog alert =AlertDialog(
      title: Text('Contact us'),
      content: ,
      actions: [
        TextButton(
          onPressed: () async {
            await launch(emailLanuch.toString());
          },
          child: Text("[email protected]"),
        ),
      ],
    );
    showDialog(
      context: context,
      builder: (BuildContext context){
        return alert;
      },
    );
  }
Uri emailLanuch = Uri(
    scheme: 'mailto',
    path: "[email protected]",
  );
  showAlertDialog(BuildContext context) {

    AlertDialog alert =AlertDialog(
      title: Text('Contact us'),
      content: ,
      actions: [
        TextButton(
          onPressed: () async {
            await launch(emailLanuch.toString());
          },
          child: Text("[email protected]"),
        ),
      ],
    );
    showDialog(
      context: context,
      builder: (BuildContext context){
        return alert;
      },
    );
  }
画离情绘悲伤 2025-01-17 16:37:59

使用包 url_launcher:

 final Uri emailLaunchUri = Uri(
  scheme: 'StackOverFlow',
  path: 'https://stackoverflow.com',
  query: encodeQueryParameters(<String, String>{
    'subject': 'Example Subject & Symbols are allowed!'
  }),
);

launch(emailLaunchUri.toString());

Use Package url_launcher:

 final Uri emailLaunchUri = Uri(
  scheme: 'StackOverFlow',
  path: 'https://stackoverflow.com',
  query: encodeQueryParameters(<String, String>{
    'subject': 'Example Subject & Symbols are allowed!'
  }),
);

launch(emailLaunchUri.toString());
眼睛会笑 2025-01-17 16:37:59

简单来说,您可以使用此包直接发送电子邮件

email_launcher: ^1.1.1

  import 'package:email_launcher/email_launcher.dart';


Email email = Email(
    to: ['[email protected],[email protected]'],
    cc: ['[email protected]'],
    bcc: ['[email protected]'],
    subject: 'subject',
    body: 'body'
);
await EmailLauncher.launch(email);

Simply, you can use this package to send email directly

email_launcher: ^1.1.1

  import 'package:email_launcher/email_launcher.dart';


Email email = Email(
    to: ['[email protected],[email protected]'],
    cc: ['[email protected]'],
    bcc: ['[email protected]'],
    subject: 'subject',
    body: 'body'
);
await EmailLauncher.launch(email);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文