如何制作颤振超链接?
how to make flutter hyperlink?
如何在 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: **myemail@email.com**', //hyperlink
),
);
showDialog(
context: context,
builder: (BuildContext context){
return alert;
},
);
}
Flutter 原生支持富文本,但我认为这对您来说还不够。您可以使用 this package 进行操作,也可以直接处理 link。(如果需要,您应该为 link 编写自定义操作,例如下面的代码)
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
}
);
final Uri emailLaunchUri = Uri(
scheme: 'Whosebug',
path: 'https://whosebug.com',
query: encodeQueryParameters(<String, String>{
'subject': 'Example Subject & Symbols are allowed!'
}),
);
launch(emailLaunchUri.toString());
简单地说,你可以使用这个包直接发送电子邮件
import 'package:email_launcher/email_launcher.dart';
Email email = Email(
to: ['one@gmail.com,two@gmail.com'],
cc: ['foo@gmail.com'],
bcc: ['bar@gmail.com'],
subject: 'subject',
body: 'body'
);
await EmailLauncher.launch(email);
Uri emailLanuch = Uri(
scheme: 'mailto',
path: "myemail@email.com",
);
showAlertDialog(BuildContext context) {
AlertDialog alert =AlertDialog(
title: Text('Contact us'),
content: ,
actions: [
TextButton(
onPressed: () async {
await launch(emailLanuch.toString());
},
child: Text("myemail@email.com"),
),
],
);
showDialog(
context: context,
builder: (BuildContext context){
return alert;
},
);
}
如何在 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: **myemail@email.com**', //hyperlink
),
);
showDialog(
context: context,
builder: (BuildContext context){
return alert;
},
);
}
Flutter 原生支持富文本,但我认为这对您来说还不够。您可以使用 this package 进行操作,也可以直接处理 link。(如果需要,您应该为 link 编写自定义操作,例如下面的代码)
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
}
);
final Uri emailLaunchUri = Uri(
scheme: 'Whosebug',
path: 'https://whosebug.com',
query: encodeQueryParameters(<String, String>{
'subject': 'Example Subject & Symbols are allowed!'
}),
);
launch(emailLaunchUri.toString());
简单地说,你可以使用这个包直接发送电子邮件
import 'package:email_launcher/email_launcher.dart';
Email email = Email(
to: ['one@gmail.com,two@gmail.com'],
cc: ['foo@gmail.com'],
bcc: ['bar@gmail.com'],
subject: 'subject',
body: 'body'
);
await EmailLauncher.launch(email);
Uri emailLanuch = Uri(
scheme: 'mailto',
path: "myemail@email.com",
);
showAlertDialog(BuildContext context) {
AlertDialog alert =AlertDialog(
title: Text('Contact us'),
content: ,
actions: [
TextButton(
onPressed: () async {
await launch(emailLanuch.toString());
},
child: Text("myemail@email.com"),
),
],
);
showDialog(
context: context,
builder: (BuildContext context){
return alert;
},
);
}