webView flutter loads white screen sometimes

Viewed 442

I am working on app where I need to show certificate in pdf format inside WebView from specific URL. I am using webview_flutter plugin for webview.

Please consider the below mentioned code:

WebView(
  debuggingEnabled: true,
  initialUrl: Uri.encodeFull('https://docs.google.com/gview?embedded=true&url=${strUrl}'),
  javascriptMode: JavascriptMode.unrestricted,
  onProgress: (int progress) {
    print('WebView is loading (progress : $progress%)');
  },
  onWebViewCreated: (webViewController) {
  _controller.complete(webViewController);
  webViewController.clearCache();
  final cookieManager = CookieManager();
  cookieManager.clearCookies();
  },
),

Now on the progress log if the webview loads certificate properly then the progress shows like 10, 15, 30, 50, 80, 100. But in the case of white screen on no data loading progress went like 10, to directly 100. Logs are not working properly.

I couldn't use other libs or plugin, Is there any solution for same?

1 Answers

Progress in HTTP isn't an absolute so you cannot always expect a "smooth" progress. Sometimes data chunks will be received in buffers that are outside your control so this behavior isn't surprising.

Related