30
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Flutterで外部ブラウザに遷移する

Posted at

アプリの利用規約で外部ブラウザを開く実装をしたのでメモとして残しておきます。

Pluginの導入

外部ブラウザに遷移するためのプラグインが用意されています。

まずはこちらを導入をしましょう。

Installing タブの通りにやると簡単に導入できます。

実装

実装はこんな感じ

_launchURL() async {
    const url = "http://https://www.google.co.jp/";
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not Launch $url';
    }
  }

挙動

output.gif

実際にiOSの外部ブラウザ遷移が動いてます。
試してないですが、Androidもちゃんと動くはずです。

誰かの力になれば。

30
19
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?