open-mail-app-flutter
此程式庫提供查詢裝置上安裝的電子郵件應用程式並開啟這些應用程式的功能。
- 星標
- 37
- 分支
- 175
- 最近推送(UTC)
- 2024年1月17日
- 專案狀態
- 已封存
原始 README
以下為英文專案原文快照,最新內容請造訪 GitHub。
Open Mail App Flutter 
A boring but accurate name.
This library provides the ability to query the device for installed email apps and open those apps.
If you just want to compose an email or open any app with a mailto: link, you are looking for url_launcher.
Why
While url_launcher can help you compose an email or open the default email app, it doesn't give you control over which is opened and it doesn't tell you what is available on the device. This is especially a problem on iOS where only the default Mail app will be opened, even if the user prefers a different app.
Setup
iOS requires you to list the URL schemes you would like to query in the Info.plist file.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>googlegmail</string>
<string>x-dispatch</string>
<string>readdle-spark</string>
<string>airmail</string>
<string>ms-outlook</string>
<string>ymail</string>
<string>fastmail</string>
<string>superhuman</string>
<string>protonmail</string>
</array>
Please file issues to add popular email apps you would like to see on iOS. They need to be added to both your app's Info.plist and in the source of this library.
Usage
Open Mail App With Picker If Multiple
import 'package:open_mail_app/open_mail_app.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return RaisedButton(
child: Text("Open Mail App"),
onPressed: () async {
// Android: Will open mail app or show native picker.
// iOS: Will open mail app if single mail app found.
var result = await OpenMailApp.openMailApp();
// If no mail apps found, show error
if (!result.didOpen && !result.canOpen) {
showNoMailAppsDialog(context);
// iOS: if multiple mail apps found, show dialog to select.
// There is no native intent/default app system in iOS so
// you have to do it yourself.
} else if (!result.didOpen && result.canOpen) {
showDialog(
context: context,
builder: (_) {
return MailAppPickerDialog(
mailApps: result.options,
);
},
);
}
},
);
}
void showNoMailAppsDialog(BuildContext context) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text("Open Mail App"),
content: Text("No mail apps installed"),
actions: <Widget>[
FlatButton(
child: Text("OK"),
onPressed: () {
Navigator.pop(context);
},
)
],
);
},
);
}
}
使用的依賴
依賴清單 4 項
- platform
^3.1.0 - url_launcher
^6.0.2 - flutter
{"sdk":"flutter"} - flutter_test開發依賴
{"sdk":"flutter"}
如何選擇適合專案的儲存庫?
先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
- 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
- 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
- 使用前在 GitHub 確認 README、授權條款與 Issues。
來源與維護
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗