LoginSignup
2
0

More than 3 years have passed since last update.

[Flutter for Web] ボタン押したら外部リンクに飛んで欲しい時

Last updated at Posted at 2019-05-25

前書き

Flutter for Web はいわゆるSPA向けのようで、現時点ではボタンポチッとして外部リンクを開くことも(多分)出来ない
が、任意のjsは実行できる。

方法

dart:jsを読み込んでopenを実行する。

import 'dart:js' as js;

FlatButton(
  child: Text("Button"),
  onPressed: () {
    js.context.callMethod("open", ["https://stackoverflow.com/questions/ask"]);
  },
)

参考: https://stackoverflow.com/a/56224693

2
0
0

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
2
0