我的 url_launcher 有两个问题:^5.7.10 第一个问题:当我尝试在真实设备上发送带有 html 标记的电子邮件时,如果我使用 Gmail 应用程序,我的电子邮件正文格式不正确。我看到了 HTML 标签。我尝试使用或不使用 HTML5 doctype 第二个问题:当我尝试发送带有 Href 标记的电子邮件时,电子邮件正文在等号处被剪切。
我的代码是
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'URL Launcher',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'URL Launcher'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Future<void> _sendMailHtml(String url) async {
if (await canLaunch(url)) {
await launch(
url
);
} else {
throw 'Could not launch $url';
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: ListView(
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: () => setState(() {
_launched = _sendMailHtml('mailto:smith@example.org?subject=News&body=<h1>Header 1</h1><p>Paragraph</p>');
}),
child: const Text('Send Mail HTML'),
),
RaisedButton(
onPressed: () => setState(() {
_launched = _sendMailHtml('mailto:smith@example.org?subject=News&body=<h1>Header 1</h1><p>Paragraph</p><a href="https://google.com">Link</a><p>End of mail</p>');
}),
child: const Text('Send Mail HTML With HREF'),
),
],
),
],
),
);
}
}
我的 pubspec.yaml 是
name: flutter_app
description: A new Flutter application.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
url_launcher: ^5.7.10
cupertino_icons: ^1.0.0
dev_dependencies:
flutter_test:
sdk: flutter
# The following section is specific to Flutter.
flutter:
uses-material-design: true
我没有尝试使用颤振 2,因为我的应用程序正在生产中并且我有一些依赖项错误。
对于第一个问题,如果我尝试使用另一个电子邮件应用程序,我可以看到良好的格式。
在安卓 10...
截图: