shinonome-inc / qiita_client_yo

【模擬開発案件】Qiitaクライアントアプリ(PlayGroundモバイルコース最終課題)
3 stars 0 forks source link

【質問】showModalBottomSheet内でWebViewをスクロールする方法 #6

Closed KobayashiYoh closed 2 years ago

KobayashiYoh commented 2 years ago

概要

Flutter最終課題のFeedPageについて質問です。 現在、記事一覧をタップして記事ページを表示させる実装に取り組んでいるのですが、showModalBottomSheet内でWebViewをスクロールすることができません。 スクロールを可能にするにはどのようなことをすべきですか?

実装したい内容

showModalBottomSheet内において、WebViewで表示されるQiitaの記事をスクロール可能にする

試したこと

DraggableScrollableSheetは使ってみました。 しかし、自分の使い方が良くなかったのか、WebViewが表示されなくなってしまいました。

ソースコード

feed_page.dart

import 'package:flutter/material.dart';
import 'package:mobile_qiita_app/services/client.dart';
import 'package:mobile_qiita_app/services/article.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:mobile_qiita_app/views/error_views.dart';

class FeedPage extends StatefulWidget {
  const FeedPage({Key? key}) : super(key: key);

  @override
  _FeedPageState createState() => _FeedPageState();
}

class _FeedPageState extends State<FeedPage> {

  late Future<List<Article>> _futureArticles;

  // 取得した記事の内容を整理して表示
  Widget _articleWidget(Article article) {
    return ListTile(
      onTap: () {
        _showArticle(article);
      },
      leading: CircleAvatar(
        radius: 25,
        backgroundImage: NetworkImage(article.user.iconUrl),
      ),
      title: Text(
        article.title,
        overflow: TextOverflow.ellipsis,
        maxLines: 2,
      ),
      subtitle: Container(
        padding: const EdgeInsets.only(bottom: 10),
        decoration: BoxDecoration(
          border: Border(
            bottom: BorderSide(
              color: const Color(0xEFEFF0FF),
              width: 1.0,
            ),
          ),
        ),
        child: Text(
          '${article.user.id} 投稿日: ${article.created_at.substring(0, 10)} LGTM: ${article.likes_count}',
        ),
      ),
    );
  }

  // ・記事項目タップで13-Qiita Article Pageへ遷移する
  void _showArticle(Article article) {
    showModalBottomSheet(
      context: context,
      isScrollControlled: true,
      shape: RoundedRectangleBorder(
        borderRadius: const BorderRadius.vertical(top: Radius.circular(25.0)),
      ),
      builder: (BuildContext context) => Container(
        height: MediaQuery.of(context).size.height * 0.95,
        color: Colors.transparent,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Container(
              decoration: BoxDecoration(
                borderRadius: const BorderRadius.vertical(top: Radius.circular(25.0)),
                color: const Color(0xF7F7F7FF),
              ),
              height: 59.0,
              child: Center(
                child: const Text(
                  'Article',
                  style: TextStyle(
                    fontSize: 19.0,
                    fontFamily: 'Pacifico',
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            ),
            Expanded(
              child: WebView(
                initialUrl: article.url,
              ),
            ),
          ],
        ),
      ),
    );
  }

  // 再読み込みする
  void _reload() {
    setState(() {
      _futureArticles = Client.fetchArticle();
    });
  }

  @override
  void initState() {
    super.initState();
    _futureArticles = Client.fetchArticle();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: PreferredSize(
        preferredSize: const Size.fromHeight(128.0),
        child: Container(
          decoration: BoxDecoration(
            border: Border(
              bottom: BorderSide(
                color: const Color(0xEFEFF0FF),
                width: 1.5,
              ),
            ),
          ),
          child: SafeArea(
            child: Column(
              children: <Widget>[
                Container(
                  height: 70.0,
                  alignment: Alignment.center,
                  child: const Text(
                    'Feed',
                    style: TextStyle(
                      color: Colors.black,
                      fontFamily: 'Pacifico',
                      fontSize: 22.0,
                    ),
                  ),
                ),
                Container(
                  width: 380.0,
                  height: 40.0,
                  padding: const EdgeInsets.only(left: 10.0),
                  decoration: BoxDecoration(
                    color: const Color(0xEFEFF0FF),
                    borderRadius: BorderRadius.circular(10.0),
                  ),
                  child: TextField(
                    enabled: true,
                    decoration: InputDecoration(
                      border: InputBorder.none,
                      icon: const Icon(Icons.search),
                      hintText: 'search',
                      hintStyle: TextStyle(
                        color: const Color(0xFF828282),
                        fontSize: 18.0,
                      ),
                    ),
                    onChanged: (e) {
                      print(e);
                      // ・Search Barに任意のテキストを入力すると記事の検索ができる
                    },
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
      body: FutureBuilder(
        future: _futureArticles,
        builder: (BuildContext context, AsyncSnapshot snapshot) {
          List<Widget> children = [];
          MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start;
          if (snapshot.connectionState == ConnectionState.done) {
            if (snapshot.hasData) {
              children = <Widget> [
                Flexible(
                  child: ListView.builder(
                    shrinkWrap: true,
                    itemCount: snapshot.data.length,
                    itemBuilder: (context, index) {
                      return _articleWidget(snapshot.data[index]);
                    },
                  ),
                ),
              ];
            }
            else if (snapshot.hasError) {
              children = <Widget> [
                ErrorView.errorViewWidget(_reload),
              ];
            }
          }
          else {
            mainAxisAlignment = MainAxisAlignment.center;
            children = <Widget> [
              Center(
                child: CircularProgressIndicator(),
              ),
            ];
          }
          return Column(
            mainAxisAlignment: mainAxisAlignment,
            children: children,
          );
        },
      ),
    );
  }
}

画像・動画

実際にスクロールしようとしているところです。

https://user-images.githubusercontent.com/82624334/146925797-8b838dd6-6bfe-461a-a9f9-71b4e1ec6c19.mp4

KobayashiYoh commented 2 years ago

https://github.com/shinonome-inc/mobile_Arugon/issues/7 このissueを参考に実装を行った結果、下記のようなエラーが表示されてエミュレーターが強制的に再起動されてしまう現象が発生しました。

Performing hot restart...
Syncing files to device AOSP on IA Emulator...
Restarted application in 3,162ms.
I/WebViewFactory(24823): Loading com.android.chrome version 69.0.3497.100 (code 349710017)
I/obile_qiita_ap(24823): The ClassLoaderContext is a special shared library.
I/cr_LibraryLoader(24823): Time to load native libraries: 8 ms (timestamps 5023-5031)
E/cr_VariationsUtils(24823): Failed reading seed file "/data/user/0/com.example.mobile_qiita_app/app_webview/variations_seed": /data/user/0/com.example.mobile_qiita_app/app_webview/variations_seed (No such file or directory)
I/chromium(24823): [INFO:library_loader_hooks.cc(36)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_LibraryLoader(24823): Expected native library version number "69.0.3497.100", actual native library version number "69.0.3497.100"
W/cr_ChildProcLH(24823): Create a new ChildConnectionAllocator with package name = com.android.chrome, sandboxed = true
I/cr_BrowserStartup(24823): Initializing chromium process, singleProcess=false
W/obile_qiita_ap(24823): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;-><init>(Landroid/content/Context;I)V (light greylist, reflection)
W/obile_qiita_ap(24823): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V (light greylist, reflection)
W/obile_qiita_ap(24823): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/obile_qiita_ap(24823): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/obile_qiita_ap(24823): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/obile_qiita_ap(24823): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextSelection;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/obile_qiita_ap(24823): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
W/obile_qiita_ap(24823): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent; (light greylist, reflection)
D/HostConnection(24823): HostConnection::get() New Host Connection established 0xc8332160, tid 25210
D/HostConnection(24823): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_2 
E/chromium(24823): [ERROR:gl_surface_egl.cc(335)] eglChooseConfig failed with error EGL_SUCCESS
W/cr_media(24823): Requires BLUETOOTH permission
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(24823): eglCreateContext: 0xb3570680: maj 2 min 0 rcv 2
D/EGL_emulation(24823): eglMakeCurrent: 0xb3570680: ver 2 0 (tinfo 0xb3551cd0)
D/EGL_emulation(24823): eglMakeCurrent: 0xe0a47a00: ver 2 0 (tinfo 0xcbc7f4d0)
W/VideoCapabilities(24823): Unrecognized profile 4 for video/hevc
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
I/VideoCapabilities(24823): Unsupported profile 4 for video/mp4v-es
W/cr_MediaCodecUtil(24823): HW encoder for video/avc is not available on this device.
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 7 0
W/cr_CrashFileManager(24823): /data/user/0/com.example.mobile_qiita_app/cache/WebView/Crash Reports does not exist or is not a directory
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/HostConnection(24823): HostConnection::get() New Host Connection established 0xe09af3d0, tid 24972
D/HostConnection(24823): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_2 
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/chromium(24823): [ERROR:gl_surface_egl.cc(335)] eglChooseConfig failed with error EGL_SUCCESS
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(24823): eglCreateContext: 0xe0a45a80: maj 2 min 0 rcv 2
D/EGL_emulation(24823): eglMakeCurrent: 0xe0a45a80: ver 2 0 (tinfo 0xb3551cd0)
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 2 (2) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/HostConnection(24823): HostConnection::get() New Host Connection established 0xc8331da0, tid 24845
D/HostConnection(24823): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_2 
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/HostConnection(24823): HostConnection::get() New Host Connection established 0xacc04ef0, tid 24843
D/HostConnection(24823): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_2 
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 2 (2) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 3 (3) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 5 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
I/chromium(24823): [INFO:CONSOLE(16)] "Uncaught ReferenceError: td is not defined", source: https://qiita.com/PanoramaDataInsights2021/items/354a15a5bb4ba2a1d71e (16)
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 5 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 5 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 2 (2) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 5 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 5 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 4 (4) 0 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 5 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 5 0
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
E/eglCodecCommon(24823): glUtilsParamSize: unknow param 0x000085b5
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 0 (0) 5 0
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 1 (1) 0 0
W/PlatformViewsController(24823): Creating a virtual display of size: [1440, 30058] may result in problems(https://github.com/flutter/flutter/issues/2897).It is larger than the device screen size: [1440, 2392].
D/eglCodecCommon(24823): setVertexArrayObject: set vao to 2 (2) 0 0
E/AndroidRuntime(17362): *** FATAL EXCEPTION IN SYSTEM PROCESS: ActivityManager
E/AndroidRuntime(17362): android.view.Surface$OutOfResourcesException
E/AndroidRuntime(17362):    at android.view.SurfaceControl.nativeCreate(Native Method)
E/AndroidRuntime(17362):    at android.view.SurfaceControl.<init>(SurfaceControl.java:590)
E/AndroidRuntime(17362):    at android.view.SurfaceControl.<init>(SurfaceControl.java:60)
E/AndroidRuntime(17362):    at android.view.SurfaceControl$Builder.build(SurfaceControl.java:377)
E/AndroidRuntime(17362):    at com.android.server.wm.DisplayContent.<init>(DisplayContent.java:777)
E/AndroidRuntime(17362):    at com.android.server.wm.RootWindowContainer.createDisplayContent(RootWindowContainer.java:219)
E/AndroidRuntime(17362):    at com.android.server.wm.DisplayWindowController.<init>(DisplayWindowController.java:44)
E/AndroidRuntime(17362):    at com.android.server.am.ActivityDisplay.createWindowContainerController(ActivityDisplay.java:125)
E/AndroidRuntime(17362):    at com.android.server.am.ActivityDisplay.<init>(ActivityDisplay.java:120)
E/AndroidRuntime(17362):    at com.android.server.am.ActivityStackSupervisor.getActivityDisplayOrCreateLocked(ActivityStackSupervisor.java:4323)
E/AndroidRuntime(17362):    at com.android.server.am.ActivityStackSupervisor.handleDisplayAdded(ActivityStackSupervisor.java:4284)
E/AndroidRuntime(17362):    at com.android.server.am.ActivityStackSupervisor.access$100(ActivityStackSupervisor.java:192)
E/AndroidRuntime(17362):    at com.android.server.am.ActivityStackSupervisor$ActivityStackSupervisorHandler.handleMessage(ActivityStackSupervisor.java:4733)
E/AndroidRuntime(17362):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(17362):    at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(17362):    at android.os.HandlerThread.run(HandlerThread.java:65)
E/AndroidRuntime(17362):    at com.android.server.ServiceThread.run(ServiceThread.java:44)
E/MethodChannel#flutter/platform_views(24823): Failed to handle method call
E/MethodChannel#flutter/platform_views(24823): java.lang.RuntimeException: InputChannel is not initialized.
E/MethodChannel#flutter/platform_views(24823):  at android.view.InputEventReceiver.nativeInit(Native Method)
E/MethodChannel#flutter/platform_views(24823):  at android.view.InputEventReceiver.<init>(InputEventReceiver.java:70)
E/MethodChannel#flutter/platform_views(24823):  at android.view.ViewRootImpl$WindowInputEventReceiver.<init>(ViewRootImpl.java:7190)
E/MethodChannel#flutter/platform_views(24823):  at android.view.ViewRootImpl.setView(ViewRootImpl.java:847)
E/MethodChannel#flutter/platform_views(24823):  at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
E/MethodChannel#flutter/platform_views(24823):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
E/MethodChannel#flutter/platform_views(24823):  at android.app.Dialog.show(Dialog.java:329)
E/MethodChannel#flutter/platform_views(24823):  at android.app.Presentation.show(Presentation.java:249)
E/MethodChannel#flutter/platform_views(24823):  at io.flutter.plugin.platform.VirtualDisplayController.resize(VirtualDisplayController.java:161)
E/MethodChannel#flutter/platform_views(24823):  at io.flutter.plugin.platform.PlatformViewsController$1.resizePlatformView(PlatformViewsController.java:285)
E/MethodChannel#flutter/platform_views(24823):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.resize(PlatformViewsChannel.java:138)
E/MethodChannel#flutter/platform_views(24823):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:65)
E/MethodChannel#flutter/platform_views(24823):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#flutter/platform_views(24823):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#flutter/platform_views(24823):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#flutter/platform_views(24823):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter/platform_views(24823):  at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#flutter/platform_views(24823):  at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#flutter/platform_views(24823):  at android.app.ActivityThread.main(ActivityThread.java:6669)
E/MethodChannel#flutter/platform_views(24823):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform_views(24823):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#flutter/platform_views(24823):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/Surface (24823): queueBuffer: error queuing buffer to SurfaceTexture, -19
E/EGL_emulation(24823): tid 24888: swapBuffers(570): error 0x300d (EGL_BAD_SURFACE)
W/OpenGLRenderer(24823): swapBuffers encountered EGL error 12301 on 0xcbc2b180, halting rendering...
D/EGL_emulation(24823): eglMakeCurrent: 0xe0a47a00: ver 2 0 (tinfo 0xcbc7f4d0)
E/flutter (24823): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(error, InputChannel is not initialized., null, java.lang.RuntimeException: InputChannel is not initialized.
E/flutter (24823):  at android.view.InputEventReceiver.nativeInit(Native Method)
E/flutter (24823):  at android.view.InputEventReceiver.<init>(InputEventReceiver.java:70)
E/flutter (24823):  at android.view.ViewRootImpl$WindowInputEventReceiver.<init>(ViewRootImpl.java:7190)
E/flutter (24823):  at android.view.ViewRootImpl.setView(ViewRootImpl.java:847)
E/flutter (24823):  at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
E/flutter (24823):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
E/flutter (24823):  at android.app.Dialog.show(Dialog.java:329)
E/flutter (24823):  at android.app.Presentation.show(Presentation.java:249)
E/flutter (24823):  at io.flutter.plugin.platform.VirtualDisplayController.resize(VirtualDisplayController.java:161)
E/flutter (24823):  at io.flutter.plugin.platform.PlatformViewsController$1.resizePlatformView(PlatformViewsController.java:285)
E/flutter (24823):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.resize(PlatformViewsChannel.java:138)
E/flutter (24823):  at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:65)
E/flutter (24823):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (24823):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (24823):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/flutter (24823):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (24823):  at android.os.MessageQueue.next(MessageQueue.java:326)
E/flutter (24823):  at android.os.Looper.loop(Looper.java:160)
E/flutter (24823):  at android.app.ActivityThread.main(ActivityThread.java:6669)
E/flutter (24823):  at java.lang.reflect.Method.invoke(Native Method)
E/flutter (24823):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/flutter (24823):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter (24823): )
E/flutter (24823): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7)
E/flutter (24823): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
E/flutter (24823): <asynchronous suspension>
E/flutter (24823): #2      TextureAndroidViewController.setSize (package:flutter/src/services/platform_views.dart:1009:5)
E/flutter (24823): <asynchronous suspension>
E/flutter (24823): #3      RenderAndroidView._sizePlatformView (package:flutter/src/rendering/platform_view.dart:193:7)
E/flutter (24823): <asynchronous suspension>
E/flutter (24823): 
D/AndroidRuntime(24823): Shutting down VM
E/AndroidRuntime(24823): FATAL EXCEPTION: main
E/AndroidRuntime(24823): Process: com.example.mobile_qiita_app, PID: 24823
E/AndroidRuntime(24823): DeadSystemException: The system died; earlier logs will point to the root cause
I/Process (24823): Sending signal. PID: 24823 SIG: 9
Lost connection to device.
KobayashiYoh commented 2 years ago
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(error, InputChannel is not initialized., null, java.lang.RuntimeException: InputChannel is not initialized.

実行結果からヒントになりそうな行を見つけたので、このエラーを基に原因を探ることにしました。 その結果、このエラーにAndroidのプラットフォームが関係しているのではないかという結論に至りました。 WebViewでプラットフォームといえばif (Platform.isAndroid) WebView.platform = AndroidWebView(); というコードを以前に見たことがあったため、試してみました。 その結果、エミュレータが強制再起動されることも無くなり、WebViewがshowModalBottomSheet内でスクロールできるようになりました。

参考 https://stackoverflow.com/questions/34039657/what-might-be-the-reason-for-this-exception-java-lang-runtimeexception-inputch https://issuetracker.google.com/issues/37018931 https://pub.dev/packages/webview_flutter