【发布时间】:2020-01-19 05:44:49
【问题描述】:
您好,我尝试使用recipent 启动电子邮件页面。我尝试了使用 android 但不适用于我的 ios 的颤振电子邮件发件人。所以我尝试了 url 启动器来做同样的事情,但不适用于 iOS。我使用iOS模拟器,问题可能是这个?
我使用这个url启动器的例子
mailto:xxxxx@xxxxx.com?subject=News&body=New%20plugin
我有这个错误
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: Could not launch mailto:xxxx@xxxx.com?subject=News&body=New%20plugin
#0 _menuscreenState._launchURL (package:xxxx/bottom.dart:8285:7)
<asynchronous suspension>
#1 _menuscreenState.build.<anonymous closure>.<anonymous closure> (package:xxxx/bottom.dart:8705:13)
这是 url 启动器的完整示例
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String email="contact@ouiquit.com";
_launchEmail() async {
if (await canLaunch("mailto:$email")) {
await launch("mailto:$email");
} else {
throw 'Could not launch';
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(primaryColor: Colors.red),
home: Scaffold(
appBar: AppBar(
title: Text('test mail'),
actions: <Widget>[
IconButton(
onPressed: _launchEmail,
icon: Icon(Icons.send),
)
],
),
),
);
}
}
这是错误
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
#0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
<asynchronous suspension>
#1 canLaunch (package:url_launcher/url_launcher.dart:112:25)
<asynchronous suspension>
#2 _MyAppState._launchEmail (package:testmail/main.dart:20:15)
<asynchronous suspension>
#3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:654:14)
#4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:729:32)
#5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
#7 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:275:7)
#8 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/<…>
【问题讨论】:
标签: flutter