3

I have an issue where the Flutter WebView is rendering blank on the release version of my Android App on the Playstore.

Users are complaining that a page is not loading, but this page was loading very fine in debug mode.

Here is what I am doing. I am loading a local html file from my assets folder as shown in the code below:

import 'package:webview_flutter/webview_flutter.dart';

class _InvoicePageState extends ResumableState<InvoicePage>
    with SingleTickerProviderStateMixin {
  WebViewController? _webViewController;


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

  void loadPage()async{
  String html = await rootBundle.loadString('assets/html/invoice.html');
  _webViewController?.loadUrl(Uri.dataFromString(html ,
            mimeType: 'text/html', encoding: Encoding.getByName('utf-8'))
        .toString());
  }

  //Then in my build Method I have this
  ....
      WebView(
               onWebViewCreated:
              (WebViewController webViewController) {
               _webViewController = webViewController;
               loadPage();
                            },
                          ),

What could be wrong, why is it loading in debug mode but not loading in release mode?

My users are already dropping really bad reviews.

Please help.

Thank you.

ololo
  • 1,326
  • 2
  • 14
  • 47

1 Answers1

0

The library's official example has InAppWebView embedded inside Stack which is further embedded inside Expanded. That is causing the issue. Try removing the Stack and Expanded or if you really want Stack, then first embed InAppWebView inside Expanded and then remove the parent Expanded.

Karanveer Singh
  • 961
  • 12
  • 27