gpt4 book ai didi

email - 使用 Flutter 发送邮件时出现 Mailer Error

转载 作者:IT王子 更新时间:2023-10-29 06:37:46 35 4
gpt4 key购买 nike

我实际上正在使用 Flutter 开发一个移动应用程序,我希望我可以从它发送一封电子邮件。为此,我尝试使用带有以下代码的 Mailer 插件:

import 'package:flutter/material.dart';
import 'package:mailer2/mailer.dart';

main() {

var options = new GmailSmtpOptions()
..username = 'mer*******@gmail.com'
..password = '*******';

var emailTransport = new SmtpTransport(options);

// Create our mail/envelope.
var envelope = new Envelope()
..from = 'mer*******@gmail.com'
..recipients.add('*******@*****.fr')
..subject = 'Testing the Dart Mailer library'
..text = 'This is a cool email message. Whats up? 語'
..html = '<h1>Test</h1><p>Hey!</p>';

// Email it.
emailTransport.send(envelope)
.then((envelope) => print('Email sent!'))
.catchError((e) => print('Error occurred: $e'));
}

但是,我有以下错误:

I/flutter (22531): Error occurred: type '_AsBroadcastStream<dynamic>' is not a subtype of type 'Stream<Envelope>' where
I/flutter (22531): _AsBroadcastStream is from dart:async
I/flutter (22531): Stream is from dart:async
I/flutter (22531): Envelope is from package:mailer/mailer.dart

有人可以帮助我吗?提前致谢!

最佳答案

在这个文件中

mailer-1.1.4/lib/src/smtp/smtp_client.dart

通过添加“cast()”方法将第 49 和 50 行更新为:


onIdle = _onIdleController.stream.asBroadcastStream().cast();
onSend = _onSendController.stream.asBroadcastStream().cast();

关于email - 使用 Flutter 发送邮件时出现 Mailer Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50217216/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com