2022年1月31日月曜日

Avoid using web-only libraries outside Flutter web plugin packages.と怒られる

 Flutter web でブラウザをリロードされた際に、その時表示されていたページによって処理を分岐したくて、dart:htmlをimportしてwindow.location.hrefでURLを取得していたら、Avoid using web-only libraries outside Flutter web plugin packages.と怒られるのだが、じゃあ、どうすればいいんだよ!としばらく放置していた。

Uri.base を使えばいいそうだ。

The natural base URI for the current platform.

When running in a browser this is the current URL of the current page (from window.location.href).

When not running in a browser this is the file URI referencing the current working directory.

 

0 件のコメント:

コメントを投稿