Почтовый Ошибка при отправке почты с Flutter - PullRequest
0 голосов
/ 07 мая 2018

Я на самом деле разрабатываю мобильное приложение с помощью 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

Может ли кто-нибудь мне помочь? Заранее спасибо!

1 Ответ

0 голосов
/ 09 мая 2018

В этом файле

почтовая программа-1.1.4 / Библиотека / SRC / SMTP / smtp_client.dart

Обновите строки 49 и 50, добавив метод "cast ()":

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...