【发布时间】:2020-12-25 04:21:25
【问题描述】:
我为我的 Flutter Web 应用添加了通过电子邮件发送反馈的功能。这是我的代码:
static void launchEmail(String subjectLine) async {
const emailId = Constants.ARUDITO_EMAIL;
print('opening email app for uploading content');
String url = "mailto:$emailId?subject=$subjectLine";
if (kIsWeb) {
if (await webLauncher.UrlLauncherPlugin().canLaunch(url)) {
await webLauncher.UrlLauncherPlugin().launch(
url,
useWebView: true,
enableDomStorage: true,
enableJavaScript: true,
useSafariVC: true,
webOnlyWindowName: 'Arudito',
headers: null,
universalLinksOnly: false,
);
} else {
throw 'Could not open an email app';
}
} else {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not open an email app';
}
}
}
pubspec.yaml 包括:
dependencies:
flutter:
sdk: flutter
url_launcher: ^5.4.2
url_launcher_web: ^0.1.3+1
此代码未在网络浏览器中启动电子邮件。它只会打开一个新标签。但是,它是在 Windows 中选择邮件应用程序时启动的。有人可以告诉这里是什么问题吗?
【问题讨论】:
标签: flutter url flutter-dependencies flutter-web