3
1

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 3 years have passed since last update.

iOS SimulatorでFlutter WebViewのlocalhost参照でページが真っ白になる件

Last updated at Posted at 2020-02-16

Flutter WebViewでlocalhostのBasic認証ページを参照した際、ページが真っ白の状態で何も表示されない現象に遭遇した。

iOS Simulatorは13.2を使用。

[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.14.6 18G87, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.42.0)
[✓] Connected device (2 available)

結論から言うと、接続先をlocalhostとしていたところを、ホストマシンのローカルループバックアドレス127.0.0.1にすることで解消された。

iOS SimulatorのSafari上で直接アクセスした際は問題なくページ参照できたが、FlutterアプリのWebView経由ではAndroid Emulatorと同じくIPアドレスに置き換える必要があるということなのだろうか。
Android Emulatorでnet::ERR_CONNECTION_REFUSEDが出た時の対処法 - Qiita

StackOverflow等でそれらしい情報は得られたが、詳細仕様についてのドキュメントが見つからず…いまいちモヤる。

If you have a server running on the machine where you iOS simulator is running, then you need to choose 'http://127.0.0.1' as the URL.
swift - ios simulator access localhost server - Stack Overflow

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?