Home > database >  Flutter RefreshIndicator not displaying in column
Flutter RefreshIndicator not displaying in column

Time:04-14

I'm trying to implement RefreshIndicator in a webview , for that I wrap my web view in a column. Problem is RefreshIndicator not displaying in top. I have tried by wrap column into a singlechildscrollview then given physics: const AlwaysScrollableScrollPhysics(), but getting exception RenderBox was not laid out. How can I fix the issue ?

body:RefreshIndicator(
                    onRefresh: ()=>webViewController.reload(),
                    child: Column(
                    children: [
                     Expanded(
                       child: WebView(
                          javascriptMode: JavascriptMode.unrestricted,
                          userAgent: 'random',
                          initialUrl: 'https://stackoverflow.com/',

                          onWebViewCreated: (webViewController){
                            this.webViewController = webViewController;
                          },
                     ),
            ),
        ],
    ),
),

Update :

To implement RefreshIndicator I take the hight using JavaScript , my mail dart is like below

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';


void main() {
    runApp(
        const MaterialApp(
            home: WebViewApp(),
        ),
    );
}

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

    @override
    State<WebViewApp> createState() => _WebViewAppState();
}

class _WebViewAppState extends State<WebViewApp> {
    late WebViewController webViewController;
    double pageHeight = 100;

    @override
    void initState() {
        super.initState();
    }

    @override
    Widget build(BuildContext context) {
        return WillPopScope(
        onWillPop: () async {
            if(await webViewController.canGoBack()){
                webViewController.goBack();
                
                return false;
            }else{
                return true;
            }
        },
        child: Scaffold(
                appBar: AppBar(
                    backgroundColor: const Color.fromRGBO(234, 53, 45, 1),

                    actions: [
                        IconButton(
                            onPressed: () async {
                                if(await webViewController.canGoBack()){
                                    webViewController.goBack();
                                }   
                            }, 
                            icon: const Icon(Icons.arrow_back),
                        ),
                        IconButton(
                            onPressed: ()=>webViewController.reload(), 
                            icon: const Icon(Icons.refresh)
                        )
                    ],

                    title: const Center(child: Text('GameClub')),
                ),

                body: RefreshIndicator(
                    onRefresh: ()=>webViewController.reload(),
                    child: SingleChildScrollView(
                        physics: const AlwaysScrollableScrollPhysics(),
                        child: Container(
                            height: pageHeight,
                            child: WebView(
                                javascriptMode: JavascriptMode.unrestricted,
                                userAgent: 'random',
                                initialUrl: 'https://stackoverflow.com/',
        
                                onWebViewCreated: (webViewController){
                                    this.webViewController = webViewController;
                                },
        
                                onPageFinished: (url) async{
                                    print(url);
                                    var result = await webViewController.runJavascriptReturningResult("document.body.scrollHeight");
                                    setState(() {
                                        pageHeight = double.parse(result);
                                    });
                                    print(pageHeight);
                                },
                                
                            ),
                        ),
                    ),
                ),
            ),
        );
    }
}

It's working fine in iOS also working fine in some android device, but in some device I'm getting below error and app is crashing.

signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1322)] Check failed: fml::jni::CheckException(env). 
'
    x0  0000000000000000  x1  0000000000002b4b  x2  0000000000000006  x3  0000007e2e6fbf80
    x4  0000007f46d3a000  x5  0000007f46d3a000  x6  0000007f46d3a000  x7  0000000000014d86
    x8  00000000000000f0  x9  0000007f41327758  x10 ffffff80fffffbdf  x11 0000000000000001
    x12 0000000006ccb638  x13 000000000000007e  x14 0000000000000000  x15 00003726b09d97f7
    x16 0000007f413f9948  x17 0000007f413d8860  x18 0000007e27ba4000  x19 00000000000000ac
    x20 0000000000000994  x21 00000000000000b2  x22 0000000000002b4b  x23 00000000ffffffff
    x24 b400007e9dd43300  x25 0000000000000000  x26 0000000000000001  x27 0000000000000058
    x28 0000000000000001  x29 0000007e2e6fc000
    lr  0000007f4138b6dc  sp  0000007e2e6fbf60  pc  0000007f4138b70c  pst 0000000000000000
backtrace:
      #00 pc 000000000008a70c  /apex/com.android.runtime/lib64/bionic/libc.so (abort 180) (BuildId: 7c95cc0d17d92058007afa23409fd94e)
      #01 pc 000000000157198c  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #02 pc 0000000001596574  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #03 pc 000000000157d410  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #04 pc 000000000157311c  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #05 pc 0000000001572f6c  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #06 pc 00000000018a5df8  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #07 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #08 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #09 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #10 pc 00000000018a109c  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #11 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #12 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #13 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #14 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #15 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #16 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #17 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #18 pc 00000000018a4df8  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #19 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #20 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #21 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #22 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #23 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #24 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #25 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #26 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #27 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #28 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #29 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #30 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #31 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #32 pc 00000000018a6154  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #33 pc 00000000018a1db4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #34 pc 00000000018a3bf0  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #35 pc 000000000189e61c  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #36 pc 00000000018be5b0  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #37 pc 00000000018bd2d4  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #38 pc 00000000018bd214  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #39 pc 00000000018c9c68  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #40 pc 0000000001597270  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #41 pc 000000000159cb18  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #42 pc 000000000001a064  /system/lib64/libutils.so (android::Looper::pollInner(int) 916) (BuildId: f7e62c203d9645802caa9325d785d7c9)
      #43 pc 0000000000019c68  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**) 112) (BuildId: f7e62c203d9645802caa9325d785d7c9)
      #44 pc 0000000000012d3c  /system/lib64/libandroid.so (ALooper_pollOnce 100) (BuildId: 10de2d6f967fb8ad85698934e9083484)
      #45 pc 000000000159caa0  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #46 pc 00000000015971b8  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #47 pc 000000000159b0b0  /data/app/~~5SmOQySJK0F1SQIw6tqeig==/jp.gameclub-ZPQ1Wl9D3eFyyC4__phffA==/lib/arm64/libflutter.so (BuildId: 143c02cfaea003573afbb914721a1287aab39908)
      #48 pc 00000000000ed098  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*) 64) (BuildId: 7c95cc0d17d92058007afa23409fd94e)
      #49 pc 000000000008cb10  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread 64) (BuildId: 7c95cc0d17d92058007afa23409fd94e)

CodePudding user response:

Try out this

Container(
              height:double.maxFinite,
              width: double.maxFinite,
              child: RefreshIndicator(
                onRefresh: ()=>webViewController.reload(),
                child: Column(
                  children: [
                    Expanded(
                      child: WebView(
                        javascriptMode: JavascriptMode.unrestricted,
                        userAgent: 'random',
                        initialUrl: 'https://stackoverflow.com/',

                        onWebViewCreated: (webViewController){
                          this.webViewController = webViewController;
                        },
                      ),
                    ),
                  ],
                ),
              ),
            ),

CodePudding user response:

Column wrap to Expanded and try

  • Related