facebook twitter hatena line email

「Flutter/外部ライブラリ/url launcher」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ブラウザ起動サンプル)
(以下エラーが起こる場合)
行35: 行35:
 
==以下エラーが起こる場合==
 
==以下エラーが起こる場合==
 
  [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
 
  [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
 +
 +
おそらく再ビルドしてないためで、以下実行か、
 +
$ flutter clean
 +
 +
androidStudioでビルド停止から起動するなどするとよい。
 +
 +
https://github.com/flutter/flutter/issues/10967

2019年11月15日 (金) 15:24時点における版

url launcherとは

外部起動させるもので、メールやブラウザを起動できる。

公式

https://pub.dev/packages/url_launcher

インストール

pubspec.yaml

dependencies:
  url_launcher: 5.2.5

メール起動サンプル

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

ブラウザ起動サンプル

_launchURL() async {
  const url = 'https://flutter.dev';
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw 'Could not launch $url';
  }
}

参考:https://qiita.com/superman9387/items/868ce6ad60b3c177bff1

以下エラーが起こる場合

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)

おそらく再ビルドしてないためで、以下実行か、

$ flutter clean

androidStudioでビルド停止から起動するなどするとよい。

https://github.com/flutter/flutter/issues/10967