LoginSignup
3
1

More than 3 years have passed since last update.

[Flutter] iOS で WebView の Scrollbar の位置がずれる問題を修正する

Posted at

Flutter で Web ページを表示する

webview_flutter を使いますが iOS デバイスで表示すると Scrollbar の位置が変なところに出るという報告があります。

普通に WebView を表示すると、

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(),
        body: WebView(
            initialUrl: "https://www.google.com/",
            javascriptMode: JavascriptMode.unrestricted,
          )
       );
  }

test2.gif

確かに位置がずれます。

スレッドをみてみたら「ClipRect で包むととりあえず回避できる」とコメントがあったので試してみました。

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(),
        body: ClipRect(
          child: WebView(
            initialUrl: "https://www.google.com/",
            javascriptMode: JavascriptMode.unrestricted,
          ),
        ));
  }

test1.gif

確かに直ってますね。

元の原因を追ってはいないのですが WebView を使う場合はとりあえずこの方法で回避できそうです。

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