enough_mail_flutter 2.1.0 copy "enough_mail_flutter: ^2.1.0" to clipboard
enough_mail_flutter: ^2.1.0 copied to clipboard

Widgets for email apps that use the `enough_mail` library. Licensed commercially friendly under MPL 2.0.

example/enough_mail_flutter_example.dart

import 'package:enough_mail/enough_mail.dart';
import 'package:enough_mail_flutter/enough_mail_flutter.dart';
import 'package:flutter/widgets.dart';

/// Example implementation for displaying the message contents.
///
/// When required, the message contents are downloaded first.
///
/// The implementation assumes that the `size` and `envelope` information
/// have been previously downloaded,
///
/// e.g. using
/// `MailClient.fetchMessages(fetchPreference: FetchPreference.envelope)`.
Widget buildViewerForMessage(MimeMessage mimeMessage, MailClient mailClient) =>
    MimeMessageDownloader(
      mimeMessage: mimeMessage,
      mailClient: mailClient,
      onDownloaded: onMessageDownloaded,
      blockExternalImages: false,
      mailtoDelegate: handleMailto,
    );

// Example implementation of an optional onDownloaded delegate
void onMessageDownloaded(MimeMessage mimeMessage) {
  // update other things to show eg attachment view, e.g.:
  //setState(() {});
}

/// Example implementation for displaying a message for which the contents
/// already have been downloaded:
Widget buildViewerForDownloadedMessage(MimeMessage mimeMessage) =>
    MimeMessageViewer(
      mimeMessage: mimeMessage,
      blockExternalImages: false,
      mailtoDelegate: handleMailto,
    );

/// Example implementation for a mailto delegate
Future handleMailto(Uri mailto, MimeMessage mimeMessage) {
  // in reality you would get this from your account data
  final fromAddress = MailAddress('My Name', 'email@domain.com');
  final messageBuilder =
      MessageBuilder.prepareMailtoBasedMessage(mailto, fromAddress);
  // in reality navigate to compose screen, e.g.
  // return locator<NavigationService>()
  //     .push(Routes.mailCompose, arguments: messageBuilder);
  print('generated message: ${messageBuilder.buildMimeMessage()}');
  return Future.value();
}
4
likes
130
pub points
63%
popularity

Publisher

verified publisherenough.de

Widgets for email apps that use the `enough_mail` library. Licensed commercially friendly under MPL 2.0.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MPL-2.0 (LICENSE)

Dependencies

enough_mail, enough_mail_html, enough_media, flutter, flutter_inappwebview, url_launcher

More

Packages that depend on enough_mail_flutter