「Flutter/外部ライブラリ/url launcher」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→メール起動サンプル) |
(→メール起動サンプル) |
||
| 行15: | 行15: | ||
https://qiita.com/sekitaka_1214/items/c7b3251e3d4ea1dd4f53 | https://qiita.com/sekitaka_1214/items/c7b3251e3d4ea1dd4f53 | ||
| + | |||
| + | ==ブラウザ起動サンプル== | ||
| + | _launcherUrl() async { | ||
| + | const url = "http://https://www.google.co.jp/"; | ||
| + | if (await canLaunch(url)) { | ||
| + | await launch(url); | ||
| + | } else { | ||
| + | throw 'Could not Launch $url'; | ||
| + | } | ||
| + | } | ||
| + | https://qiita.com/superman9387/items/868ce6ad60b3c177bff1 | ||
2019年11月15日 (金) 14:40時点における版
url launcherとは
外部起動させるもので、メールやブラウザを起動できる。
インストール
pubspec.yaml
url_launcher: 3.0.0
メール起動サンプル
String url = "mailto:sample@example.com?subject=subject1&body=" + Uri.encodeComponent("本文1"); if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; }
https://qiita.com/sekitaka_1214/items/c7b3251e3d4ea1dd4f53
ブラウザ起動サンプル
_launcherUrl() async {
const url = "http://https://www.google.co.jp/";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not Launch $url';
}
}
