facebook twitter hatena line email

「Flutter/外部ライブラリ/メール送信/flutter email sender」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「==インストール== pubspec.yaml <pre> dependencies: flutter_email_sender: ^2.2.1 </pre>」)
 
(サンプル)
(同じ利用者による、間の5版が非表示)
行1: 行1:
 +
==flutter email senderとは==
 +
直でflutterからメール送信できるライブラリ
 +
 +
==公式==
 +
https://pub.dev/packages/flutter_email_sender
 +
 
==インストール==
 
==インストール==
 
pubspec.yaml
 
pubspec.yaml
行5: 行11:
 
   flutter_email_sender: ^2.2.1
 
   flutter_email_sender: ^2.2.1
 
</pre>
 
</pre>
 +
 +
==サンプル==
 +
<pre>
 +
import 'package:flutter_email_sender/flutter_email_sender.dart';
 +
final Email email = Email(
 +
  body: 'Email body',
 +
  subject: 'Email subject',
 +
  recipients: ['example@example.com'],
 +
  cc: ['cc@example.com'],
 +
  bcc: ['bcc@example.com'],
 +
  attachmentPath: '/path/to/attachment.zip',
 +
  isHTML: false,
 +
);
 +
await FlutterEmailSender.send(email);
 +
</pre>
 +
成功するとandroidだとgmailのページがアプリ内で開く。iosだと内製メーラーが開く。
 +
 +
==エラーが出てしまう==
 +
androidx対応してるライブラリっぽいので、導入側プロジェクトにandroidxが対応しておらずエラーになってた。androidx対応したところ直った。
 +
<pre>
 +
~/android/app/src/debug/AndroidManifest.xml:22:18-91 Error:
 +
Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
 +
is also present at [androidx.core:core:1.0.2] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
 +
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:11:5-34:19 to override.
 +
<pre>

2019年12月5日 (木) 21:58時点における版

flutter email senderとは

直でflutterからメール送信できるライブラリ

公式

https://pub.dev/packages/flutter_email_sender

インストール

pubspec.yaml

dependencies:
  flutter_email_sender: ^2.2.1

サンプル

import 'package:flutter_email_sender/flutter_email_sender.dart';
final Email email = Email(
  body: 'Email body',
  subject: 'Email subject',
  recipients: ['example@example.com'],
  cc: ['cc@example.com'],
  bcc: ['bcc@example.com'],
  attachmentPath: '/path/to/attachment.zip',
  isHTML: false,
);
await FlutterEmailSender.send(email);

成功するとandroidだとgmailのページがアプリ内で開く。iosだと内製メーラーが開く。

エラーが出てしまう

androidx対応してるライブラリっぽいので、導入側プロジェクトにandroidxが対応しておらずエラーになってた。androidx対応したところ直った。

~/android/app/src/debug/AndroidManifest.xml:22:18-91 Error:
	Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
	is also present at [androidx.core:core:1.0.2] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:11:5-34:19 to override.
<pre>