Zero_Bolt
Zero_Bolt

Reputation: 119

how to make flutter hyperlink?

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;
    },
  );
}

Upvotes: 1

Views: 3552

Answers (4)

Hammad Ali
Hammad Ali

Reputation: 407

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;
      },
    );
  }

Upvotes: 1

Anandh Krishnan
Anandh Krishnan

Reputation: 5986

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);

Upvotes: 1

Hammad Ali
Hammad Ali

Reputation: 407

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());

Upvotes: 1

vb10
vb10

Reputation: 681

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
  }
);

Upvotes: 2

Related Questions